For me there are a few pieces to this.
The first is fit and geometry. A bike that fits well and responds well is generally more fun to ride, but maybe not a lot faster unless your current one is way off.
There is static weight. Lighter bikes tend to feel faster and less weight climbing is better. But static weight, non moving parts such as frame, handlebars, saddle, etc, have less impact especially on flat terrain. If you lose 5 lbs in weight you are moving less weight even on the same bike.
Rotational weight is a bit different. For me, I can tell a significantly heavier wheelset from a lighter one. More so in accelerating than at speed.
Finally gearing, including the number of speeds. While I think there is merit in developing power at different cadences, having better gapping tends to maximize your speed/performance.
At one point in my cycling life I was trying to reduce unnecessary bike weight and upgrade to better components. I can’t say if it helped that much, but on a tough climb it was motivation that it ain’t the bike.
John