The major limiting factor on RPM is the valve train, and opening / closing valves without bounce to ensure compression.
2 stroke eliminates the need for valves, hence why they can rev so high. The single piston reduces weight on the crank which also helps with high rpm, and the piston gets a bang on every cycle, so theres no "dead" weight for the engine to turn on a cycle.
4 stoke motorbikes can only rev so high due to not needing a big cc due to lack of weight, therefore engine and valve train components are very light, and on the bigger engined F1 cars, the valves are opened / closed using compressed air, as a spring would never cope at that rpm on a large valve. This is another reason for more cylinders - it means each cylinder can be smaller, meaning valve can be smaller, and lighter, and more rpm can be used