In respect to this, is it illegal to put compression fittings on brake lines?
You cannot, under any circumstances, use compression fittings to repair the lines on a public transportation vehicle. Many states have banned the use of this repair on passenger vehicles, too. In addition, you might find that compression fittings will cause your vehicle to fail inspection.
Keeping this in view, are brake line unions safe?
If you are adding a nut to the cut line and double flaring it, using a brass threaded union, then yes that is 100% safe and the correct method to repair. Compression unions are used for psi in the hundreds. Not in the thousands scale of brake psi.
Flaring brake lines ensures a leak-proof connection without extra materials or sealants. If the brake lines aren't properly flared, you can lose fluid that will cause your brakes to fail. This article will explain how to flare your brake lines using single and double flares.