The classic buffer overflow has the buffer on the stack, near the return address, so you can just write a new return address and jump into the code you put in the buffer.
It's become more complex due to mitigation, but the general principle is the same.
It's become more complex due to mitigation, but the general principle is the same.