At the rear of the transmission is a "hat coupler" mounted to the stub shaft of the transmission. Attached to that is another coupler that holds the propeller shaft. That shaft coupler is attached to the transmission coupler with 4 bolts. The shaft coupler is attached to the propeller shaft with two square head machine screws and a keyway. The square headed screws are locked to the shaft coupler with two nuts.(FYI, none of the parts screws or nuts related to the shaft coupler are stainless - get some lubricating oil and bandaids for the skinned knuckles you will most likely have)
Finally, there should be a stainless wire running thru the square nuts that further prevents them from backing off the shaft.
If the shaft is turning in the coupler then one of three things probably happend
The shaft has moved aft enough that the key has fallen out. Or, somehow you have sheared off the key, or during assembly of the new engine the key was never put back in when the engine was changed
If the shaft is turning free in its coupler then it can fall out. Usually the only thing keeping it in the boat is a sacrificial zinc mounted on the shaft behind the strut. (Gambler a J/30 out of Sandusky, Ohio had this happen and nearly sunk. The shaft came out of the boat). Big hole in boat where shaft comes thru lets in a lot of water
Metal shavings could be from the shaft spinning against the bottom of the square head bolts. Could be from the shaft spinning in the coupling and wearing either the shaft or the coupling or from a sheared key
Fixes, 1st, remove the coupler from the shaft, see if there is damage to the shaft or coupling (if the screws have cut a groove in the shaft, it won't hurt anything). 2nd, get a key and put it back together 3rd, align the engine. Use feeler gage to measure distance between shaft coupler and transmission coupler (.003 max runout). Loosen the front engine mounts only. Adjust left to right and up and down