Spitballing here:
It might be anxiety-related.
A lot of people with chronic anxiety tend to get late-night zoomies because there's less pressure to perform and to do things because the world has gone to sleep and, suddenly, without all of that external pressure weighing down on that anxious mind you feel extremely motivated to do things or to revamp your life etc.
If we assume that this is the case for your experience and we assume that the major cause for your writer's block is anxiety-related (both of which are pretty plausible without actually knowing any specifics) then the logical conclusion is that you feel motivated to write at 3am not because of the positive presence of inspiration but because of the absence of anxiety, or the relief from it.
Obviously this is just wild speculation so take this guess with all due caution. It's easy enough to test whether this is the case in order to rule it in/out though and if you think it might be a fit then the next step would be looking at ways to manage your anxiety levels so that you can enjoy more creative pursuits.