Because according to this, Why Sugar Makes Us Sleepy (And Protein Wakes Us Up) | Wired Science | Wired.com, if you are eating pastries and cookies and other sweet things, you are likely feeling tired afterwards as a result. You then compensate by drinking too much coffee and hence get on a vicious circle. If you are going to be snacking on anything, make it proteins like nuts or low fat yogurt or a bean salad.
Snack smart. See the wired.com article for more of the details.