And no it’s quite likely not the the chicken the the egg problem.
Don’t get me wrong downing 3 double espresso shots 30 min before bed time is probably not a good idea however there is nothing that indicates that caffeine consumption during the day would have an impact on sleep in fact many studies showed that moderate amounts of caffeine even 2 hours before bed did not have a negative impact on sleep and a few studies even showed improvement in REM sleep when caffeine was taken but again nutrition studies are notoriously problematic.