Switching my iPhone from T-Mobile to AT&T. Will I lose all of my photos, text messages, etc?

I requested an unlock from T-Mobile and got an email telling me I can either put in a non-Tmobile sim card or use the T-Mobile sim and backup all of my data and restore. My understanding is now I can take my iPhone in to ATT and they will replace the sim card and I should be good to go. Is this correct? And if it does work smoothly like that, will I lose all of what's stored on my phone? Because it seems like when you put in a new sim card, you have to log back into your iPhone and it acts like you just bought it, so I'm worried

You shouldn't. Make a backup of photos to one of those photo sites anyway. Also, mention this concern to the TMobile guy. They deal with this issue every single day.

If your data is stored onto your phone you are good. Photos will be good, sometimes text messages are stored on sim though.

just find the option in your phone that will let you back up everything onto the phone's storage. Or do it manually by plugging it into a pc

Get all your junk downloaded before you switch.

The SIM card does not save any of that information. The SIM is like a permission slip to allow the phone to use there network. If you are concerned back up the phone to itunes using a computer or icloud. A manual itunes backup is a full backup of everything except your music and itunes content that are not apps. You probably already have icloud backup turned on without realizing it and if you have the icloud photo library turned on it will save your photos as long as icloud has enough storage.

Go to settings, tap on you name at the top. Then tap on icloud and it will show you what is being saved to icloud. Now even if messages are off in the list it will still back them up in a backup it just doesn't share them across devices. You can tap on icloud backup and it will tell you the last time the phone was backed up. The back stores personal settings. I know, I know this as I used to work on iphones.

However you want to be VERY careful if you are switching phone numbers. You probably have two factor. You WILL want to know your AppleID email and password as well as access to the email you linked to your Apple ID. Make sure you add a secondary number to your Apple id before you begin or if you're keeping your number keep another phone on the old carrier or factory unlocked handy just in case. A friend or a relative. You could get potentially locked out of your AppleID if you don't. Permanently if you don't prepare. At best you'd have to start recovery and that can take 2 weeks under manual review.

I allow people to PM me. I've been doing this since 2012 with iphones. I've seen many people epicly screw themselves out of there own data because they don't understand how things work with Apple security.