Android typically forces low-priority apps to sleep so that they don't drain your phone's battery. Putting apps to sleep means they won't consume a lot of power and won't run in the background ...
To play YouTube videos in the background while doing other things on your iPhone, you can use YouTube premium or Safari's desktop view mode.