You’re absolutely correct that you can do all that at home. Will you? I find that going to a place puts me in the right state of mind to do the thing. They do have a lot of equipment available, but you can mostly replace it at low cost by running outdoors or buying a few dumbells.
Likewise for the costume - when I started going, I was very worried about making sure I had gym shorts and running shoes and a sweat wicking shirt and a gym bag. I got that stuff and it did help, just mentally put me into the place for it. But after a while I realized I could just go in casual clothes (though my gym bans jeans) and it’s fine. Up to you what’s more motivating - workout clothes or reducing friction by wearing what you’ve got.



As for what to do there - again, it’s your call. Generally they have several flavors of weight machines, cardio machines, free weights, usually some kind of aerobics space.
You set your own goals and routines. In contrast with something like school, no one’s going to force you to exercise. You have to want to - whether that’s for the fun of it or to achieve some health result.
Gyms also tend to offer classes, or personal trainers you can hire if you want more structure.