If the foreground apps need the resources (RAM, CPU) the OS will kill apps that are in the background. There used to be various things apps could do to reduce the risk of being killed, but these options have gradually been reduced in recent years.
It sounds like the launcher app is killed while in the background. Make sure that the app is allowed to run in the background and not have any battery optimization enabled.