Horsepower is a unit of power. Power describes how fast energy is exchanged; a use of energy divided by how long it takes to use that energy. Therefore the measurement of horsepower refers to what the sustained output of an engine is. The term horsepower was invented by James Watt, who made significant improvements to the steam engine.
Although it may seem safe to assume that one horsepower is the output a horse is capable of creating at any one time, that is incorrect. In fact, the maximum output of a horse can be up to 15 horsepower, and the maximum output of a human is a bit more than a single horsepower. For extreme athletes, this output can be even higher with Tour de France riders outputting around 1.2 horsepower for around 15 seconds, and just under 0.9 horsepower for a minute.
Therefore the term "horsepower" may seem slightly misleading, but Watt did have his reasons for such a name. When Watt made his improvements to the steam engine, he understandably wanted to convince people to buy it. If he said that his expensive engine had the same short-term output as a horse, people wouldn't buy it, as they already had horses. Instead, he compared it to the amount of work a horse could do in a day, giving it the output of ten horses instead of just one. Suddenly his invention became much more tempting. Although Watt may have "bent the truth" to make his engine more appealing, he was not lying. While it is true that the maximum output of a horse is around 15 horsepower, when you average the output of a horse over the course of a work day it ends up being around a horsepower. Watt defined this amount as "the amount of work required from a horse to pull 150 pounds out of a hole that was 220 feet deep". In a similar vein, the output of an average human over the course of a day is 100 watts, which is where we get the term energy servant from. James Watt chose to compare his engine, which was capable of sustaining it's power output for a full day, to a horse's average power output over a day.
When purchasing a new car, the crib sheet includes two output numbers with the engine: horsepower and torque. If you live in the United States or Canada, those numbers will be listed with the units of SAE certified Horsepower (which is the same as horsepower, but certified by the SAE) and pound-feet. If you live in Europe, the outputs will be listed in Watts and Newton meters. The core difference between these two sets of units is that whereas horsepower is a measurement of power - referring to an amount of energy transfer over time- Newton-meters are a measurement of torque - a measurement of rotational force, which has no unit of time. In SI units, a Watt is 1 Joule per 1 Second.
Another difference between horsepower and torque is that horsepower is energy output over time, and torque is instantaneous. In the context of cars, broadly speaking, this means that a car with a lot of horsepower will have a higher top-speed than the same car with less horsepower. Similarly, a car with a lot of torque will be able to accelerate faster than the same car with less torque, as its instantaneous output will be higher.