There are a few reasons cookie dough can spread or flatten. If the dough is too warm or too soft, it will be more likely to spread. The colder the cookie dough, the thicker and sturdier the cookies will be. Soft dough may benefit from more flour. Be sure the cookie sheets are cold/room temperature before adding cookie dough.