Magic: The Gathering works like a computer (quite literally it's Turing complete). When you play a card or ability, it is put on a stack. After you're done, you need to yield - then the other player may play things on the stack too (but, they can only play "instants" - most other cards can only be played if the stack is empty). Then they must yield, and so on.
(In the 90s, instants meant to interrupt other spells were called "interrupts", but this name was dropped)
After everyone is done, things are popped from the stack in the reverse order they were played (like any stack). So if your opponent played something in response to what you played, their card resolves first, then yours. But if you played something in response to their response, your card resolves first, then theirs, then yours.
This would be very tedious, but in fact most decks have few instants and little interaction with the stack, so most of time you play a card I will just wait it to resolve and generally wait my turn to play. And famously, no card of MtG is allowed to mention the stack in their printed text: while the concept itself is intuitive, talking about the stack is a sure way to make a card overly complicated.