My memories of this kind of rectangular lamp as in the front bike are of it opening wide once you hit any bump

. The housing flexed so match along the long edge, that it opened the latch.
Ah yes, the classic 'let the light out of the box' type, which they have resolved here by making the catches so difficult to open that one considers replacing the lamp when the bulb blows...