Only data used over the cellular data network counts against the allowance with your carrier. You can use as much Wi-Fi data as your Internet Service Provider (ISP) allows. With Wi-Fi, you are sharing the data connection with other devices using the same network. So if your ISP has a limit, they count the usage by all connected devices including telephones, tablets, desktop computers, laptop computers, game consoles and voice over IP devices.
If you are downloading a large file, Wi-Fi might stop when the phone goes to sleep and the connection might switch to cellular data without your knowledge. This also can happen if you leave a Wi-Fi location before the download is completed.