Create a colored square and a white square.
Select both squares.
Go to Object > Blend > Make.
Might need to edit blend options to specified steps.