Did I just blow my money away paying off my student loan?

I borrowed a total of around £28k of student loans, basically just the tuition fees.

I am 24 years old, 3 years into my job as an accountant and I earn £55k, the salary is expected to grow because I am a little bit ambitious.

I did the math and it would’ve made more sense mathematically for me to pay off the loan.

I have a mortgage currently at 4.2% on my flat and the student loan interest is at 7.3% (plan 2)

I recently inherited some money and put it all towards the student loan balance and cleared it off but I feel stupid sometimes for doing that.

Maybe I could’ve invested it?