Hi @Lightuptheroom that's tough. I've been on both sides of this situation- as a recruiting manager filling a vacancy and secondment post, and as an applicant.
You really must get feedback. You're surprised and shocked that you didn't get the secondment, so it's important to find out why, what's missing from your skill set."Development opportunities" is how to fill these gaps.
Not getting the role might not be about your technical expertise - you might need people management skills, a wide network, comms & engagement, familiarity with xyz software - find out what's missing and work on it. There will be something, probably quite nuanced, that you havn't thought of. Honestly, is your skill set that unique?
Going forward, never turn down an opportunity to act up or get involved in something a bit different - deeper, wider, different to what you usually do. Take up your manager's development opportunities. You never know where these things will go - I nice chart a board that grew out of a comment I made at a meeting where I represented my department because no one else was interested. It will be hard work, but pushing your grade always is.
As a manager, it's different filling a secondment than a permanent post. Secondees need to hit the ground running fast. What can they bring to the role? What will they take away, how will their parent team benefit on your return, having been a person down?
And as for facing your team. Smile and wave. Shrug and accept that the best person won. Be nice to the people managing /instructing you, and get on with your job. Don't for goodness sake criticise the decision to give the job to someone else. (Not openly anyway!).