In stack algorithm, the set of pages in memory for n frames is always a subset of the set of pages that would be in memory with n+1 frames.
This means that whatever pages are present with n frames at any time, they are also present with n+1 frames.
Both optimal and LRU follow stack algorithm.
For LRU, the set of pages that would be in memory would be the n most recently referenced pages. If the number of frames is increased, these n pages will still be the most recently referenced and so will still be in memory.
But with FIFO, this is not the case. See for this reference 0, 1, 2, 3, 0, 1, 4, 0, 1, 2, 3, 4 . FIFO doesn't follow the stack algorithm. Try it with 3 and 4 frames.
See the below image where-where * is present, the set of pages with 3 frames is not the subset of set of pages present with 4 frames.