Why do penises get erect?

Your brain reacts to certain things that turns you on and then the penis get filled with blood which leads to erection. Otherwise you would not be able to have intercourse.