As I think someone said earlier, it appears that it scavenges the SSID that you originally connected with an attempts to connect using that. I've tried with 2 different chromecast dongles, starting out with my tablet on a 5Ghz network. Both times the dongle showed that same 5Ghz network during the network setup but the dongles never were able to connect that network.
When I changed the network to a 2.4Ghz network on the network setup page, it connected to that network and then at the end of the setup process my tablet was switched to that 2.4Ghz network as well! I switched my tablet back to a 5Ghz network after setup completed and still was able to cast to the dongles. All that matters after setup is that you're on the same subnet.