there's a wire element in a bulb.. it's twisted and coiled .. gets white-hot and produces light. (2 elements in a high-lo beam lamp)
the two ends of the element must somehow exit the bulb's body so it can be connected to the bike's electrical system. Various forms of "terminal" are used.. some look like those in the picture.
Here, the bulb's base has a blot of solder.. one terminal.... and the brass screw base is the other terminal.
On a bike headlamp, the terminals probably come out as "spade" terminals.. small flat, rectangular things.. and a mating female terminal on the headlamp wire's end plugs into it. There are many and various forms of terminals.. barrel, screw-connection, etc.
You can remove the bulb if it's more convenient and gives easy access, but it's not necessary..
In either case when testing with battery or meter, disconnect the lamp's wiring and then connect the battery or the meter.