Are there safety concerns or code violations with my garage sub-panel?
It is bad, more than a few violations here if I understand what is being fed.
First violation no clamps /bushings coming into the panel 2 places.
Next a 40 amp breaker feeding #12 possibly 14 awg wire 4 places
4 ground wires under 1 lug (I believe square D limits grounds to 2 wires)
The neutral and ground issue would have been legal prior to 1999
If the garage is detached a separate additional grounding conductor would be required.
I would highly recommend this getting fixed sooner than later and the ground neutral issue is the least of the issues because if the other things were not a problem and built pre99 it would be ok.
Note if you can turn off a breaker inside the house
It would be an easy fix with a 60a sub panel with a minimum of 4 circuits (go bigger) 60 amp panel 4 circuits 36$  or jump up to a 125 amp panel 12 circuits for 40$  (4 $ more double the capability and triple the circuits)
You use the existing 40 amp breaker in the house.
Purchase the new sub
Purchase 1 240v breaker 20 amp? Guessing on the wire size
Purchase 2 120v breakers 15 or 20 amp 12 awg wire 20 amp , 14 awg wire 15 amp the wire size is stamped on the cable sheath.
4 clamps
The clamps go in the knockouts the 3 circuits out each go through a clamp 1/2”
The input through a larger clamp 3/4”
Terminate the 2 hots neutral and grounds and do not install the bond screw or remove it so the ground and neutrals will be isolated.
Connect the existing 240v circuit black white on the double pole breaker and ground.
Connect each of the 120v blacks to there breaker
Then the grounds on the ground buss neutrals on the isolated neutral buss
If it is a detached garage a separate ground rod needs to be added use a 8’ rod or pair of rods at least 6’ apart connected with #6 copper wire.
That’s it turn things on and know you eliminated a major fire and safety hazard and have a little room to grow before a larger feeder would be needed.
This can be done with the existing wires a larger box should make it easy but a wire or 2 may be short. Make sure the feeder fits first. Then add small wires and splice in the panel as needed it’s code compliant.