Try with -r sub-0300_T1w.nii.gz. The image passed with -r should describe the space into which you want to resample the moving image.
I know it’s confusing because you have a 4D input image but a 3D reference image. It’s because antsApplyTransforms expects the reference image to match the dimension of the transform specified with -d, which is 3.
@gerardyu can you check the affine of your raw BIDS T1w? Sometimes these affines aren’t compatible with ITK, so we convert them to something that is compatible but maintains the correct voxel spacing.