Removing hair from hard floors is a job best handled by a slightly dampened microfiber push-broom. Avoid using a regular broom or vacuum as both of these tend to blow the hair around. Depending on how much dog or cat fur there is, you may need to replace the mop head part way through.
For carpets your best bet is to use a vacuum cleaner with powerful suction, generally the big brands like Dyson (not a sponsor!) offer superior performance to no-name Amazon brands. If you’re concerned about allergies in addition to fur, be sure to look for a vacuum which includes a HEPA filter to avoid blowing dander and allergens around.
If you have stubborn hairs stuck in your carpet, or perhaps you have too little carpet to justify buying a dedicated vacuum for, you can use a wet rubber glove or a pumice stone. Whichever you choose, simply run it lightly along the surface of your carpet. Pumice stones do a great job pushing hairs into small clumps which can be easily pinched up. Pet hair will readily cling to the rubber glove. Simply wash or wipe it off once the surface stops picking up more hairs. Don’t have a rubber glove handy? Try using the rubber side of your bathroom squeegee. Just like the glove, cat and dog fur will stick to it like a magnet.
For the tight corners where the carpet meets a wall, or on stairs, you may need to get creative. Make a loop of duct tape, sticky side out, and gently roll it into the corners. Don’t push too hard, your goal is simply to liberate the loose fur and you don’t want to leave a sticky residue behind!