This is a very interesting question, I've come across this when a client was designing a fire-code-compliant office space. The client's work was related to the defence industry and the office space had two rooms with highly classified contents.
Now, of course, if you're a 3-letter government agency, you can disregard whatever laws you want, but let's assume that we want to follow the legal procedure.
The laws are clear when it comes to building code and fire safety (in all countries it's pretty much the same, but I'll quote the one from the United States). The National Fire Protection Association Life Safety Code 101 says
Locks, if provided, shall not require the use of a key, a tool, or
special knowledge or effort for operation from the egress side.
So to comply with the laws, the client built the rooms on the side of the hallway, making them impossible to use in the path of egress, then installed a big red button that would mechanically open the door from the inside. Behind the door there's a turnstile gate (though a very different model) that would only allow egress but not entry.
The idea is simple. If your room provides a step on the egress path, then by law it must be opened in the direction of the egress path. So it all comes down to thinking about security when designing the building.
I've found this image online and I added the red arrows and text to illustrate the point (those aren't really exits and fire exits)
So, Should magnetic locks automatically release in the event of a fire alarm? The answer is, it depends.