In the scenario you mentioned where it is currently 2nd & 4 any penalty that advances the ball 4 or more yards will result in a first down. This happens because the offense just has to get the ball to a certain yard mark for the first down and it doesn’t matter if they get it through plays or penalties.
As for the second part of a question when the ball moves due to a penalty the yards to go will also change with the yardage. The exception being if it gets the team a first down or when it is 1st and 10 and the penalty gives an automatic first down.
Also this is how it works in all leagues though the yards given for each penalty may vary.
There is a special case regarding half-the-distance penalties (penalty yardage may never exceed half the distance to the conceding team's goal line). Scenario: Offense has 2nd and 8 at the defensive team's 12 yard line. The defensive team concedes a 10-yard pre-snap penalty. While the penalty is capped at half the distance (12 yards/2 = 6 yards in this case), the "original" penalty was 10 yards. In this case, even though the offense doesn't pass their 8 yard target it's a 1st down.