Horse power is torque over time. It is measure (calculation really) of how much power the engine has and how fast it can put it out.
The formula is, HP= (Torque * RPM) / 5252
So an engine with 1 ft*lbs of torque spinning at 5252 RPM will have 1 HP.
Displacement is loosely attached to HP, since displacement affects torque. More displacement the more torque you can achieve since torque in an engine is a function of pressure over the piston's travel. It's a complicated integral taking into account the pressure at ignition and the changing pressure as the piston moves down, increasing volume which decreases pressure. Typically, the more area your piston has and the longer crank travel you have, and the longer you can keep the connecting rod perpendicular to the crank shaft, the more torque you will have.
Horsepower is all about how much torque you can produce each power stroke, which is a function of initial volume, piston surface area, how far the piston will travel, and how much fuel you are burning, and how fast you can get your engine to produce power strokes. This is where motorcycle engines, especially crotch rockets, get their power from, they red line above 10k rpm usually.
This is in a perfect engine, engines are not perfect, and there are a lot of variables involved, more than I know about and can think of, that affect its performance. So the above is to be taken in a general sense, not as a gospel.
So, if you see a 150cc engine with more HP than a 300cc engine, the 150cc engine is probably capable of turning more RPM's than the 300cc engine. They are going to show the maximum horsepower attained in tests, and they will usually show you at what RPM this value was attained. The 300cc engine will produce more torque, but it won't be turning the shaft as quickly. If you got the 300cc engine and the 150cc engine spinning at the same RPM, the 300cc engine would likely be producing more horsepower, assuming no mods.