A gerund is one of the three kinds of verbals. A gerund always functions as a noun (cf. participle which is always adjectival).

Running races is my favorite form of exercise.

Here the gerund is functioning as subject of the verb “is”.
Just like the other verbals, gerunds can take objects and be modified by adverbs and prepositional phrases. In this case, the gerund together with its object and modifiers would make up a gerund phrase.