Why 45
Many schools and universities settled on about 45 minutes for a lesson, and most of us spent years working in blocks that size. It is not a measured optimum. It is simply long enough to get properly into something and short enough that you rarely hit the wall before it ends.
Between 25 and 50
If 25 minutes ends just as you get going and 50 feels like a stretch, this sits in between. Try it for a few days. If you keep finishing early, use the 50-minute timer; if you keep drifting before the end, drop back to 25.