The Messenger of Allah ﷺ prayed two rakats at Mina, and Abu Bakr did the same after him, and Umar after Abu Bakr, and Uthman during the early part of his caliphate. Then Uthman later prayed four rakats. So Ibn Umar, whenever he prayed with the imam, would pray four, but when he prayed alone, he would pray two.
و حدثنا أبو بكر بن أبي شيبة حدثنا أبو أسامة حدثنا عبيد الله عن نافع
صلى رسول الله ﷺ بمنى ركعتين وأبو بكر بعده وعمر بعد أبي بكر وعثمان صدرا من خلافته ثم إن عثمان صلى بعد أربعا فكان ابن عمر إذا صلى مع الإمام صلى أربعا وإذا صلاها وحده صلى ركعتين