Like with strength or technique there is training you can do to develop this. Training for a good mental attitude is partly about training to reduce stress and reducing the likelihood that you will freeze under pressure. It is also partly about encouraging you to understand the linkages between techniques, how to apply the technique in different situations and how a technique fits into the bigger strategic picture.
So, what's a solution? Games.
Here's a list of some that I like to use with descriptions (I'll keep updating this list as I come up with new games):
Slappy facey / tag - based on a childhood game from my upbringing in Scotland, slappy facey in it's natural form is literally walking up to someone without warning and slapping them in the face while shouting "slappy facey" usually followed by much hilarity. Translated into a fencing game "slappy facey" is just a version of tag (tig if you're from Scotland or New Zealand...) but where you designate a body part as the target (knee, shoulder or top of the head) and then you must tag other people with your hand while protecting your target.
Usually I run this as an all against all warm up with no point scoring because this means that after "hitting" your target you have to withdraw to avoid their counter attack. Generally it devolves into a great fast moving warm up with emphasis on spacial awareness (sneak attacks are the best) and ensuring that your attack actually lands (stance/posture) while defending against counter attacks.
Finger fencing - basically this is a tag based game but where you use two fingers to represent your sword. In this you can only score with the two fingers of your right hand (or left obviously if you're left handed). You can usually score by touching anywhere on the body with this game but you can designate target area to up the skill level.
You can run this as all against all for warm up or as 1 - 1 for more fencing style game. A variation on this is to use a glove in lieu of an actual weapon, thereby slapping your opponent with the glove to count a hit. This is a great game because you can run it with very free and easy with minimal protection.
Maintaining measure game - probably a standard with variations throughout all HEMA clubs, this is the one I use: two fencers face off and find measure by extending their arm and touching the other person's chest. Once they are in measure one person moves off and the other tries to follow maintaining the measure. At some point the instructor calls out "halt" and they check their measure, if the "follower" has been successful then they should still be in measure. You can liven this up by upping the speed and introducing an spacial awareness element by suggesting that the person leading tries to maneuver the follower into objects such as other fencers or walls.
Obviously a good game for developing a sense of measure, it also helps people to internalise their footwork.
Drop glove - using the rules of the maintaining measure game both people move and maintain measure, however one person is holding a glove and when they chose to drop it the other has to catch it with a lunge before it hits the ground! The glove dropper can increase the difficulty by being progressively more uncooperative in when they chose to drop the glove.
Good for measure, footwork and reaction.
Cudgels - I keep the rules for this simple. You use "safer" weapons such as foam swords, nylon wasters or Dussacks which means you generally need minimum protective gear. You find measure against your opponent while adopting a right foot forward stance. Once both players are "measured" then the back foot (the left) is now fixed. They can still move the right foot as much as they wish, which allows them to move out of measure. The only blow that counts is a head blow. Both parties go until a head blow is landed then the looser comes off and the winner stays on. I try and encourage a really fast turn around of participants.
This is good for working on middle work technique, working the openings, stance and leaning. Also it builds fitness and stamina but also benefits building a good mindset by getting people used to fencing under pressure and being hit on the mask.
Fencing cricket - simple little game: throw a tennis ball and the other person has to hit it with their weapon. You can make it more complicated by having different colours of balls which you assign a different action, such as: yellow = vertical cut, blue = diagonal cut, green = horizontal cut.
Improves reflexes and also helps encourage accuracy, it's not as easy as you might think to hit even a tennis ball sized target. Of course to make it really difficult you can always add in thrusts.
Random weapon sparring - have a selection of "safer" weapons such as wooden longswords, nylon wasters, Dussacks, plastic daggers, bucklets, light quarter staff etc. Have two contestants. Have them face away from each other and select random weapon combinations. At the command of "go" they turn, grab whichever weapons have been provided and spar. The first to a head blow wins. Immediately cycle the pair off and put a new pair up. The pair that have just come off get to select the random weapons for the new pair. Keep going until everyone is exhausted or bored.
Improves reflexes and adaptability. Encourages people to be creative while facing often radically different measures and protective capabilities. Helps people to relax in normal sparring.
Random attack and defend - everyone kit up and form a ring with one person in the ring. Assign each person around the ring a number. When that number is called they step in and perform one attack on the person in the ring. The person in the ring defends the attack. To up the ante you can get the defender to perform a counter attack and you can call multiple numbers to attack at once.
Loose play - it's also worth mentioning that any loose play can be approached as a game and this is a great thing to do to encourage people to adopt a easy, relaxed mental attitude in really sparring.
I like to build up the game by starting with an opening scenario and then adding "new rules" so it could look like this:
1. The opening scenerio is that one person attacks through a guard in onset, the defender makes a response and then the attacker changes mid-stroke to counter the response. Once complete the attacker withdraws.
2. New rule: the defender can parry the attackers blow
3. New rule: the attacker can take a further action (they get two "attacks")
4. New rule: The defender can have a further parry (they get two parries)
5. New rule: after the first attack the defender counts to two and then can do anything they like. However they can't move. So the attacker has to hit and withdraw.