Form is definitely important to preventing injury, but that doesn't mean you need to hire a trainer. Trainers can be quite expensive, especially when you are first starting out. Trainers in my experience are a better fit when you are already pretty serious and need direction to "get to the next level" or need assistance like rehabilitation therapy.
Most good gyms will have some people on staff that can help you with questions about good form. If you are unsure about good form, ask someone that works at the gym if they can come give you a look over and give some pointers.
Also, there is a reason there are mirrors all over in the gyms; it's so you can watch yourself to make sure you have good form.
One last pointer; start light. Lifting too heavy will lead to bad form and injuries. A classic example is curls; people lifting too heavy on curls will throw their back a bit on the lift and injure their back. So start light, watch your form, and slowly add those weights.
Mirrors are actually not that great at checking form - the act of looking in the mirror changes how you move. Now that just about all of us carry high quality digital HD cameras in our pockets, that's the best way to check form.
I'm maybe a little embarrassed to admit this, but paying for a trainer will help me commit. If I'm paying for an hour of time on Thursday morning, I'm more likely to show up.
That's nothing to be embarrassed about. It's hard to commit until you're fit. Eventually you get to a point where you look forward to going to the gym if you stay with it long enough.
If you have a good trainer that can help with the commitment issue. If you have a bad trainer it can make it worse. I've had both. I had one trainer that wouldn't listen to me and just always pushed to hard; then during a session I puked from over exertion. I was so angry and embarrassed I didn't go back to the gym for over 3 months.
Anyway the point there is if you are going to get a trainer then vet them before you sign an agreement.
A couple of other options to help with commitment is to join a fitness group or a class like Farrell's (https://extremebodyshaping.com/).
Some of these have support/accountability groups so if you no show someone is going to call and ask where you were and in return you do the same thing
Most good gyms will have some people on staff that can help you with questions about good form. If you are unsure about good form, ask someone that works at the gym if they can come give you a look over and give some pointers.
Also, there is a reason there are mirrors all over in the gyms; it's so you can watch yourself to make sure you have good form.
One last pointer; start light. Lifting too heavy will lead to bad form and injuries. A classic example is curls; people lifting too heavy on curls will throw their back a bit on the lift and injure their back. So start light, watch your form, and slowly add those weights.