Function is not tied to the scale degrees, function is determined through the manner in which the chord interacts with the chords around it. The three main functions are tonic, subdominant, and dominant. The mediant can function as a tonic because you can see it as a 7 chord with an omitted root. Or, you can see the mediant as a subdominant 6 chord. How you will analyze the chord will depend on the larger progression.