The fungus is digesting partly decomposed organic matter in the potting mix. They do not harm the plant. Also, the parts above the ground is only the reproductive body, you can remove them if you don't like the look, and the mycelia will still work on the medium.
Throwing away or repotting the plant is unnecessary, the fungus is beneficial if anything, because it breaks down the unusable material in the pot into something the plant can access.
I'm not certain what species that is. The picture is not very clear. This isn't very important, but if you want, post closeup picture of the fungus so we can try for a positive id.
Your Sansevieria trifasciata cultivar is showing slight signs of etiolation. They tolerate dense shade, but dense shade looks a lot brighter indoors than out. Also, they (unusual) like to be root-bound. From the picture, it looks like you are doing a good job keeping the mix dry, but I'd provide just a little more light.