Thats called shimmying, How old is the tank, what are its water params, how big is the tank, How many fish are in it etc. If its a new tank the shimmying is probably due to high nitrites through an uncycled tank. Shimmying is caused by stress and bad water conditions is one reason why they do it