The obvious answer would be you drank some type of beverage with caffeine in it. You could have also taken a nap during the day and are now struggling to sleep because your body feels like it already has enough sleep. There is many science behind , but if I were you I wouldn’t stress about it and just do what you can do. Your body knows what is best so don’t force anything!