The term allegedly dates back to when radio was first adopted by the U.S. Navy.
It is claimed that originally, a small wooden structure similar to a shed, was placed on deck to house the ship’s radio equipment.
This became known as the “radio shack”. The name has stuck and is now applied to anywhere the radio equipment is used.
If you know of a different reason for the radio room to be called a shack, I’d be interested to know…