In order for a space vessel’s energy weapon to pass through its own shield, its energy frequency must match. Otherwise, one would be damaging its own shield from within.
This frequency is, by year 9599, a 128-digit number and there is virtually zero chance of an opponent guessing a ship’s frequency. The chance is further lowered by a feature where a ship’s OS can adjust its frequency every second. A fleet can also synchronize shield frequency in order to minimize friendly fire during battles.
An actual incident of an opponent bypassing shields had never occurred until the alien invasion where an entire different kind of weapon was used against shields.