Python 2, 226 224 bytes
-1 byte thanks to Trelzevir
x,i,n=input() g=lambda x,i:[eval("_.replace(' ','').%sjust(len(_))"%['l','r'][i%2])for _ in x] f=lambda x,i:i<2and map(''.join,zip(*g(map(''.join,zip(*x)),i)))or g(x,i) for i in([0,3,1,2]*n)[i:i+n]:x=f(x,i);print'\n'.join(x) Try it online!
Function that remove all spaces of each element in the list and complete with spaces on left or right.
g=lambda x,i:[eval("_.replace(' ','').%sjust(len(_))"%['l','r'][i%2])for _ in x] Function to transpose (rotate 90º) when the input is 0 or 1(U or D) and apply g
f=lambda x,i:i<2and map(''.join,zip(*g(map(''.join,zip(*x)),i)))or g(x,i)