There are several causes of noisy pipes. Yours sounds like water hammer and perhaps, poorly secured pipes. Water hammer is a loud banging sound. It occurs when a valve is closed quickly and the water, which is moving with considerable velocity and momentum, has to stop very quickly. When water moving at several feet per second has to stop abruptly, there is a considerable amount of force that must be dealt with. The water bounces off the valve and actually creates a vacuum as it bounces away from the valve. The vacuum then violently attracts the water back to the low pressure area and the water again bounces off the closed valve. If the water has enough momentum, it will again bounce off the valve and create a smaller vacuum. The effect of this is reverberation, which sounds a little bit like someone pounding on metal piping with a hammer. Water velocities can be high (up to 3,000 miles per hour) and the forces developed with water hammer can exceed 600 psi. The implications of water hammer can include deterioration of valves, loosening of piping supports and leaking at pipe joints. Metal piping is more susceptible to water hammer than plastic piping. The plastic piping tends to have enough flexibility to absorb some of the energy.
A water hammer chamber could be installed behind the toilet. It will act like a cushion and slow the water down gradually. Poorly secured pipes may require the ceiling below to be opened up to access the pipes, however if the water hammer problem is eliminated, the pipes may not move enough to make noise.