There are three similar cases.
There are traffic lights where the pedestrians usually have a red light and only
get a green light if they request it by pushing a button.
This seems to be the case in your question.
A pedestrian is required to push the button and wait.
(A slight variant has induction loops to detect bicycles, but pedestrians are still required to push.)
There are traffic lights which are switched off until a pedestrian pushes a button.
A pedestrian is not required to push, in that case the normal rules for an intersection/road without traffic lights apply.
(Once somebody touches the button and there is a red light, you have to wait ...)
There are audible signals for visually impaired pedestrians which can be activated by a similar-looking box.
There have been examples of the first case where the button has no effect and the green light comes according to schedule anyway.
Either this has been done as a placebo to keep pedestrians from crossing at a red light, or the traffic lights of the intersection are not configured as originally inteded and the button wasn't removed.
travel.stackexchange.com/users/27778/o.m.
Also note that sometimes the main traffic lights directing vehicles operate on their own schedule, and are not effected by the button, but the button controls the operation of the pedestrian walk/don't walk light.
So for example, when there is a separate light for traffic turning left off the main road, across the pedestrian crosswalk, the walk/don't walk light will normally be red, but will turn green only if both the button has been pressed and the left-turn light is not active; ie.
it is letting pedestrians to know whether it is safe to cross so they don't have to figure out what is going on with the vehicle traffic lights in a complicated intersection.
travel.stackexchange.com/users/40926/jkf
The ones in Heidelberg are required to get a green light as a pedestrian.
If you don't press them, it never turns green, it is green for the cars all the time.
You said in comments that it turns green anyway, but somebody else must have pressed either the light on your side or on the opposite side.
For lights in other cities, other rules may apply, as discussed in other answers.
travel.stackexchange.com/users/1397/rumtscho
In my city in Spain, those buttons reduce 1/3 the time of waiting during day schedule, and, during the night, the pedestrian lights won't ever turn green unless they are pressed.
travel.stackexchange.com/users/37002/CptEric
Depends on the traffic light system in use in the particular city or at the particular traffic light.
Some, particularly in less busy areas (usually crossing a single street) keep the vehicle lights green unless someone pushes the button.
Some (intersections) skip the pedestrian light cycle and keep them red if no button is pressed.
Certain intersections, particularly busy ones, stick to their cycle and have no button or sometimes even buttons with no effect (other than a little LED), just to give you the idea of having done something :)
travel.stackexchange.com/users/40963/7dude
I've been to Heidelberg, Germany recently and I've found things like this in most traffic lights in the city:   If I press it a message that says "bitte warten" (please wait) appears. This is not common where I come from so I don't know if pressing has any additional effect.  Does pressing reduce the waiting time? Or does it just display the message?
Button for pedestrian traffic lights in Germany
travel.stackexchange.com
<europe><germany><walking>
travel.stackexchange.com/questions/64800
travel.stackexchange.com/users/33096/A. A.
This depends on the traffic light system and sometimes the particular traffic light, but the ones in Heidelberg require you to press the button to get a green light, and otherwise cycle through the main traffic lights. The way the lights for cars and pedestrians interact at traffic lights depends on the traffic light system in use. However, In Hiedelberg, the pedestrian lights only turn green when activated by a pedestrian.
The way the lights for cars and pedestrians interact at traffic lights depends on the traffic light system in use. In Hiedelberg, the pedestrian lights only turn green when activated by a pedestrian