There needs to be proper blood flow in the groin to make it hard or cause erection. Working out improves the blood flow and helps in erection. But if you're excessively working out or have any diseases like peyronie disease , low libido, then you still can find problems in erection.