Talking to colleagues helped him to "come to terms with the enormous sadness" of what had happened, he added, pointing out that "things can snowball and get quite bad" if there is not the right support at work.
It is not known whether the child William was referring to survived or died, but such incidents were common when he worked for the East Anglia Air Ambulance from 2015 to 2017 before becoming a full-time working royal.
Speaking at the This Can Happen conference at the O2 in London, which aims to address mental health issues in the workplace, the 36-year-old father of three said he was offered professional help.
He said: "I was lucky enough that I identified that something was going on and I spoke to a lot of people about it.
"And that talking and that dealing with it, and knowing also that my colleagues I worked with had been in the medical profession for 30 odd years in some cases, they were all also feeling from this particular job very troubled.
"We regularly used to talk about it and try and understand it better. It helped me to come to terms with just the enormous sadness I'd witnessed."
Revealing how he forced himself to "disconnect" from the work, he added: "I started to realise that I had to self-analyse a bit. I was seeing a lot of death and a lot of injury, a lot of traumatic injury and families being destroyed every single day I was at work.
"And you start to think, without realising it, that life is like that the whole time. The negativity creeps up on you so much that you have to distance yourself from the job a little bit, and go 'OK this happens in the job environment but the whole world isn't this gloomy and really sad".
About 120 employers from different sectors were represented at the event, which was attended by roughly 750 people. It was organised by Neil Laybourn and Jonny Benjamin who have helped the Duke and Duchess of Cambridge and Prince Harry with their Heads Together mental health campaign after Neil stopped Jonny jumping off Waterloo Bridge five years ago.
Urging employers to look after the mental health of workers, William added: "We spend a vast amount of our time at work. There should be a much more open, supportive and compassionate working environment to deal with those sorts of problems.
"There's still a stigma about mental health. We are chipping away at it but that wall needs to be smashed down."
He also spoke about the responsibility of looking after his own staff, who he said sometimes work "silly hours".
It is important they "keep an eye on the hours they work" and the commuting they do, he added.
Mr Laybourn, who ran last year's marathon for the Heads Together campaign, said: "It's quite something for him in his position to say 'you're not infallible'."
WHERE TO GET HELP:
If you are worried about your or someone else's mental health, the best place to get help is your GP or local mental health provider. However, if you or someone else is in danger or endangering others, call police immediately on 111.
OR IF YOU NEED TO TALK TO SOMEONE ELSE:
• LIFELINE: 0800 543 354 or text HELP to 4357 (available 24/7)
• SUICIDE CRISIS HELPLINE: 0508 828 865 (0508 TAUTOKO) (available 24/7)
• YOUTHLINE: 0800 376 633
• NEED TO TALK? Free call or text 1737 (available 24/7)
• KIDSLINE: 0800 543 754 (available 24/7)
• WHATSUP: 0800 942 8787 (1pm to 11pm)
• DEPRESSION HELPLINE: 0800 111 757