Cookies can flatten in the oven for various reasons. The first is too little flour or too much butter. Not chilling the dough. Lastly, not preheating the oven to the correct baking temperature.