Just like nouns and noun phrases, gerunds and gerund phrases can be used as objects in sentences/clauses. They can be used as both direct objects as well as objects of prepositions:
Gerund as a direct object: Helena has mastered fencing.
Gerund phrase as a direct object: They hate mowing the lawn.
Gerund as an object of a preposition: He quickly resorted to begging.
Gerund phrase as an object of a preposition: Holidays are perfect for visiting family.