Routine procedure after shutting in a main is to drain the system at a low point before doing any plumbing work. Even if the system isn't drained, air will get in the lines any time the main is closed. That air will find it's way out of the pipes eventually, usually through sinks and toilets (and washing machine lines) at higher points in the system.
Air is compressible, water is not. When the water is turned back on, you have a bunch of air bubbles moving through the pipe. The little "slugs" of water between the air bubbles get forced through with tremendous energy and they act like little battering rams when they turn corners, hit valves, etc. That effect is called hammering. It is super common to have old pipes or bad connections fail when you're putting a system back in service after shutting it in and draining it. I'd bet this is what happening for you.
Does the laundry box your hot and cold water supply lines come off have something that look like these little bits of extra pipe?
These are called hammer arrestors and they work like little springs in a hydraulic system. They can "absorb" small amounts of pressure spikes in the water system to protect connections and equipment from bursting.
Put them in if they aren't there already.
Also make sure the supply line is not cracked and the little rubber gasket in the female end of the supply line is in good shape. Replace if not. If there isn't a gasket on purpose, be sure to put teflon tape on the threads of the male end on the washing machine before making up the connection.
Also, if you know the water was shut off, try to purge the air from the lines from the sinks near your washer first as a best practice. Just try to prevent the hammering from hitting the washing machine if you can.
Last, let your building manager/maintenance people know this happens every time they shut the water off and you'll be sending them the invoice for repairing fixtures, appliances or water damage if they don't get their S together and start recommissioning the system properly. Suggest they put in hammer arrestors or coin vents at high points in common areas.
Good luck