A stack retrieves whatever item was added most recently, last in first out, while a queue retrieves whatever item was added first, first in first out. That single ordering difference is exactly why undo history in a text editor uses a stack, the most recent action is the first one you'd want to undo, while a printer's job list uses a queue, the first document sent should be the first one printed, and using the wrong structure for a given job produces a program that runs without error but returns items in exactly the wrong order.
A stack's last-in-first-out order fits problems with a natural reversal
Undo and redo functionality, a web browser's back button, and a program's own function call stack all rely on last-in-first-out order, whatever happened most recently is exactly what needs to be undone, revisited or returned to first. Parsing nested expressions, matching opening and closing brackets, or tracking recursive function calls all lean on a stack for the same underlying reason, the most recently opened thing has to be the first one closed.
A queue's first-in-first-out order fits problems that need fairness over time
Task scheduling, message queues, and breadth-first graph traversal all rely on first-in-first-out order, whatever arrived first genuinely should be handled first, skipping ahead of an earlier item would be a real correctness bug, not just a stylistic choice. A print queue is the clearest everyday example, a document sent five minutes ago shouldn't have to wait behind one just submitted, which is exactly the fairness a queue's ordering guarantees and a stack's ordering would actively violate.
What we're still unsure about
That stacks and queues guarantee genuinely different retrieval orders, and that picking the wrong one for a given problem produces incorrect rather than merely inefficient behaviour, is well established, uncontroversial computer science. What's more a genuinely open, practical question is which specific underlying implementation, an array-based structure or a linked-list-based one, actually performs best for a given real workload, the two implementations carry different memory and speed trade-offs that aren't always predictable from big-O complexity alone, and picking the faster one in practice usually needs actual benchmarking rather than reasoning about the abstract interface in isolation.
This sits inside Stacks & Queues, one of eight topics in Data Structures, one of seven domains in Computer Science, one of seventeen subjects the app can quiz you on.