1. Create a colored square and a white square.
  2. Select both squares.
  3. Go to Object > Blend > Make.

Might need to edit blend options to specified steps.