If you're curious what's going on when you shift, there are two different disconnects. One is in the center axle assembly and one is in the transfer case. When you're driving in 2wd the front driveshaft and the front differential ring gear are stationary, this reduces vibration and noise and also saves a little bit of fuel, and makes the truck a little more responsive because it doesn't have to spin up and spin down a heavy and fast spinning bunch of metal every time you accelerate and decelerate.
The disconnect in the front axle takes the place of what used to be manual hubs in the old days. This prevents the tires from turning the front driveshaft just by being rolled down the road. There's a little stub shaft that spins backward in response to forward input from the tires rolling on the road. That stub shaft has a splined disconnect and as you can probably guess, you can't just pop that on and off while it's spinning the opposite direction of the CV axle on the other side.
In the transfer case there is a an electrically actuated clutch that connects and disconnects the front output of the transfer case, and prevents the engine from spinning the front driveshaft and differential while you're in 2wd. Since it's a clutch it's meant to slip a little bit without experiencing much wear.
On the part time transfer cases (trucks which don't have auto 4wd), when you shift from 2H to 4H the truck first engages that clutch in the transfer case. The clutch slips a little bit but brings the front driveshaft up to speed. That eliminates the counter-rotation of the stub shaft in the front axle and then the splined disconnect in the front axle can join the left and right wheels together without grinding. This is why there is a delay between selecting the shift and the truck finalizing it, it needs time to spin up the front driveshaft and also time to measure its speed before connecting the front axle shafts together.
The reason it's good to understand all of this is that it helps to understand when you shift from 2H to 4H the clutches in your transfer case do experience a little bit of wear. This is by design, but it's still wear. That means the faster you're traveling when you shift the more wear occurs. If you are sympathetic to the machine and want it to last as long as possible you can choose to slow down a bit before shifting just to minimize the amount of wear it experiences. That all comes down to your relationship with machines I know a lot of people don't care at all and it's their own truck they're free to do what they want with it.
The trucks with auto-4wd have a similar arrangement but a different clutch mechanism. When the truck is in auto-4wd mode it just leaves the front axle connected full time and slips the transfer case in and out of engagement on the fly.
I hope this helps.