Chances are, the cupcakes were underbaked. Make sure to test with a toothpick when the timer goes off. It needs to come out completely clean! Overfilling can also cause the tops of cupcakes to collapse, so make sure you're filling the liners the correct amount, about 4 tablespoons. One last things that could cause issues is if your baking powder is old and will not give lift to the cupcakes. To test if your baking powder is still fresh, add a teaspoon to some hot water. It should bubble up right away. If it doesn't, throw it out and buy more.