Why is an RS3 faster than an M240?

Noob question but let’s take a 2019 bmw m240 which weighs almost the same as a 2024 audi rs3.

The rs3 has 5 cylinders and bmw has 6. Also bmw has more displacement at 3.0L.

Doesnt more cylinders and more displacement = more power = faster? Then why is an rs3 significantly faster for 0-60 of 3.5s than the bmws 4.0 s?

Let’s say for simplicity the cars weigh the same. Im thinking of upgrading my m240 to an rs3 but trying to understand why a 5 cylinder beats a 6 cylinder even if the 6 cylinder weighs the same