Pet vacuums work by the same overall mechanism as a regular vacuum. They just have a few alterations which render them better for dealing with the challenges of pet hair and dander.
Inside your vacuum, an electric motor spins a fan. As the fan blades turn, they force air into the machine, and towards an exhaust port. This mechanism drives dirt particles up into the vacuum. A filter placed over the exhaust port allows air to escape, but traps the dirt particles inside.