Horsepower (hp) = Torque (ft lb) * rpm / 5252. So, if you want to increase hp of your 4.0 OHV which make max power at 4200, remove lifters/pushrods/rockers, and make a SOHC so it revs higher and makes max power at 5250 and you easily get 25% more power. But note torque peak rpms increased by 25%.
Torque is more complex. Torque (ft lb) = displacement * compression ratio * volumetric efficiency * air density / fancy constant.
Displacement is pretty much set by initial engine design
Compression ratio depends on fuel specified and combustion chamber burn rate
Volumetric efficiency is controlled by intake and exhaust ports (includes everything from air filter to muffler).
Air density is function of altitude - here in Calgary at kilometer high, I get less than those at sea level; temperature - more power at -40C in winter than in summer at 40C, and density adders (supercharger - either crank, electric or turbine driven).
You can build same power out of a smaller engine for the same amount of time, if you use better materials. And over time, we have improved materials, but the downside is it comes at higher cost.