Both sentences contain the same four components:
1. subject = people
2. object = her
3. action = rush
4. reason for the action = rescue
Although "rescue" in the first sentence looks like a verb, it is actually part of the infinitive "to rescue", which functions as an adverb, to describe the verb "rush". The abverbal phrase "to rescue her" gives reason for the verb "rush", as in "The reason peope rush is to rescue her".
In the second sentence, "rescue" is a noun, as part of the prepositional phrase "to her rescue", which functions as an abverbal phrase, to describe the verb "rush". The abverbal phrase "to her rescue" gives reason for the verb "rush", as in "The reason peope rush is for going to her rescue".