These are grammatically correct sentences. They are indeed a little hard to parse (particularly for a nonnative speaker) since they are (as you note) somewhat haphazardly constructed.
The first explains that the time spent in the lounge watching TV and taking study breaks was how the speaker got to know a lot of people. If they had just stayed in their room studying they would not have met other students.
The second says that students could save commuting costs if they figured out how several could ride at once in one car.
(In the first example I have used the singular first person "they" to refer to that student. I don't know how TOEFL is dealing with current controversy in English about those pronouns. In years past I'd have written "If he or she had ...".)
Edit in response to comment.
I'm not a grammar expert. I just know what sounds right. Here are my best grammar guesses.
In the first example,
just watching TV and taking study breaks in the lounge.
is the object of the prepositional phrase that starts with an implicit "by".
In the second,
getting to campus
is not how they save money. That would be by knowing about rideshare. The sentence assumes you know implicitly that
They are getting to campus in separate cars.
So "getting to campus" is the object of the verb in that implicit separate sentence.