Why is my iPhone using 4G data when in range of my WiFi?
When the phone is asleep (also known as hibernation mode), the WiFi radio is shut off after a time to conserve battery power. Anything that occurs on the phone, such as receiving notifications, background app updates, et cetera, uses the cellular network instead of WiFi. The one notable exception would be iCloud backup, for which the phone wakes the WiFi radio.