I ran my first few 10k's in approx 48 mins. It didn't matter that one was flat, another hilly, one was off road, and another was multi terrain and undulating.
As a beginner and training for a marathon I was stuck in that slow marathon plod. Not running short and fast or varrying my pace enough. I only started doing shorter runs about a year ago. My 5 and 10k times dropped by several minutes each. This year I was going to target 5k's but my immune system broke.
I'm only reitterating what has been said, train for the distance. If you are marathon training at present don't compromise that by trying to go for 10k PB's at the same time. Concentrate on your marathon and building endurance. You want to be as best prepared for that physically and mentally as you can.
When you have run your marathon you can start to target your 45 min 10k goal. As you have discovered, running fast for a prolonged distance is as much mental as it is physical.
Remember also that you are training to race. Your training runs are not races. Don't time them and think that's it. They are just training runs. Race in a proper race where you will be psyched up to push yourself both mentally and physically.
Don't beat yourself up about a training run that wasn't as fast as you wanted. That's just going to make you feel bad about your running. That's not what it's about.
Enjoy, relax.