For dot-ca, it (used to be) historically mandated that you had to use the 'closest' geographic locale for your domain, which is how we got https://transit.toronto.on.ca (which now goes to https://transittoronto.ca).
At some point CIRA (the non-profit that now runs .ca) stopped making that a requirement.
* https://en.wikipedia.org/wiki/.ca
There are still rules on who gets priority on names: toronto.ca is the government but toronto.com is a news organization; ditto for canada.ca and canada.com; ontario.ca versus ontario.com; etc.
The three/four-level domains are now generally grandfathered.