Belgium international defender Kompany, 26, who is a doubt for Saturday's trip to Newcastle due to a groin problem, condemned the incidents.
"It is never a good thing to happen, not just for Manchester City or Manchester United, but for football," added Kompany, speaking to Football Focus during City's annual visit to Royal Manchester Children's Hospital.
"I would definitely say we need action on prevention but keep treating fans as human beings and not animals that have to be behind cages.
Ferdinand later played down the incident on Twitter, writing "what a shot!"
"I do think we should take action against these incidents and I have heard a lot of suggestions about putting up nets and everything.
"But the fact we are able to put people outside of cages is something that makes the English game so much more special."
City keeper Joe Hart also had to stop a fan who had run on to the pitch from reaching Ferdinand as the defender recovered from the blow.
In October, Sheffield Wednesday goalkeeper Chris Kirkland was attacked by a fan who ran onto the pitch during his side's match against Leeds United at Hillsborough.
Kirkland, 31, required treatment after he was struck in the face during the Yorkshire derby, which ended in a 1-1 draw.
However the chairman of the Football Supporters' Federation, Malcolm Clarke, warned against "knee jerk" reactions. He said safety was improving at games and pointed to government figures showing arrests were down 24% on previous seasons.
Football Focus is on BBC One at 12:15 GMT this Saturday
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.