Sine wave amplitude modulation - Analysis using Audacity
Your samples have a finite bitwidth. For example, assume your samples have 16 bit width; if you increase their amplitude beyond what these 16 bit can represent, you end up with an overflow.

In case your audio samples being signed integers, that overflow typically first manifests as a sign inversion – exactly what you're seeing here. (That's because only the lower 15 bits in your 16 bit signed integer are actually the number – the uppest bit is the sign; you shift a 1 there, the result becomes a negative number in 2-complement represenation.)

This isn't a limitation of audio processing only – in fact, integer limits is something basically (nearly) every programmer needs to be (slightly) aware of. Your number variables can't hold arbitrarily large values!