In which software you see this? Can you reproduce it with Slicer sample data sets?
The forum is not suitable for collaborating on code that is longer than a few lines, so if you share code then upload to GitHub instead and just post the link here.
This is a wrong assumption. DICOM stores image position and orientation, therefore it is not necessary to resample the image to apply arbitrary translations and rotations. Since information is lost and image quality is decreased when you resample a rotated image (unless you resample on a very high resolution grid, which is usually not a practical solution), it should be avoided, if possible.
You will only see the image content rotated in a “non-rotated” volume if you resample the volume using a non-rotated volume as reference. But again, this should not be necessary and somewhat lossy operation.
In contrast to most other software, Slicer exposes inherent complexities in medical image computing, which may be hidden in clinical software (to make things simpler and safer for users; but it means that there are many limitations, many operations are simply prohibited) and in custom in-house software (which often make incorrect assumptions, such as “image axis directions are always the same as anatomical axis directions”). Fortunately, Slicer has all the necessary tools to deal with these complexities, you just have to learn what is happening and why, and how you want to deal with them.