Memory is managed by the applications and policed by iOS.
Apps are programmed with what they are going to do when they are transitioned too inactive and background states.
Inactive state they will just be quiet and minimize, if not eliminate resource usage.
Background state they will save user data, free resources for foreground apps and make a snapshot for the multitasking switcher.
The type of app and how it was programmed to function going into its background state will determine how it appears when it gets back to the foreground. This is why some apps will have a brief reload and put you back where you left off, or nearly where you left off. Other apps will appear like they are starting for the first time. News apps and social media apps generally do the later, they need to dump the resources used by their 'feed'. Coincidentally this also keeps current events current.
If the background app doesn't free enough (or any) resources and the foreground app needs those resources then iOS will jettison the background app entirely to obtain the resources your foreground app needs to function. Keep in mind, its either the background app closes or the foreground app doesn't open.
Obvious problem with this is it requires optimization for specific devices if your app is (or can be) a resource hog. And of course there are exceptions to this with apps that have background privileges. So regardless of how many apps you open your music keeps playing and your phone calls dont hang up (although both can effect app performance via iOS memory warning system).