A spacewalk occurs when an astronaut leaves their spacecraft while in space. But in fact, they only ever (deliberately) do this while still in another spacecraft - a tightly fitting one we call a spacesuit. So, conceptually it's hard to rigorously define the difference between a spacesuit and a spaceship (I am not convinced that definitions involving flexibility are meaningful.) Nevertheless, to date there have not been any cases that are really ambiguous.
In particular, for my purposes I define a spacewalk as an activity carried out in vacuum conditions protected only by a (not rigourously defined) spacesuit. And by `vacuum conditions', I specifically mean an ambient pressure of less than 50 mbar (5 kPa). I chose this arbitrary value to be `basically vacuum'; I note that the point at which US spacewalkers are told they are near enough to vacuum to open the airlock hatch is 34 mbar, not too different. On the other hand, during Apollo NASA used 241 mbar to mark start and end of spacewalks, and currently uses 345 mbar as a point to pause depressurization for leak checks, so I don't claim I have a strong argument for this particular value.
When airlocks are repressurized, the pressure usually rises quite quickly above the 50 mbar level, but random pressure fluctuations in a depressurized airlock are much less than this. This means that my definition doesn't create large numbers of spurious mini-spacewalks at either end of a real spacewalk (if you picked 1 mbar, for example, this might be a problem).
My definition means that I include what NASA calls `intravehicular activity', where astronauts work inside a depressurized section of a spacecraft. My view is that a spacewalk can be either when you go outside the spaceship to enter space, or equally well when you let space into the spaceship.
My 50 mbar rule means that activity on the Martian surface (with a pressure of 6 mbar) would count as spacewalking, but activity on the surface of Venus or Titan, with their much higher atmospheric pressures, would not. This is not to say that humans operating in an unbreathable atmosphere is not dangerous and/or not interesting, just that I choose to treat it as a different thing from a spacewalk. (It is in some ways more comparable to undersea diving, which also involves an unbreathable ambient environment).
Clearly, by my definition, activity on the lunar surface (Lunar EVA or LEVA), where the typical pressure is orders of magnitude below my threshold, is included.
For `spacewalk' I sometimes use the alternative but ugly term `depressurization event'. I don't like NASA's term `extravehicular activity' (EVA) since my focus is on the vacuum, not the fact that the astronaut is outside. The Russian term is ВКД (VKD) which stands for внекорабельная деятельность (vnekorabel'naya deyatel'nost') which is a direct translation of EVA. Less formally they say Выход в открытый космос (exit to open space) which has some of the same problem but is at least a bit less unpoetic.
Since 1981, NASA has measured spacewalk duration from when the suits went to internal power until the start of airlock repressurization. Prior to this, they usually used the time from depressurization to 3.5 psi until repressurization to 3.5 psi. Roskosmos and its precedecessors use the time from hatch opening to hatch closure, and China (which got its initial spacesuit tech from Russia) appears to use the same rule. As a historian, however, I balk at using different measurs for different agencies. When asking questions like `what is the longest spacewalk' you really need to use the same rules for everyone. The accuracy of my '50 mbar depress to 50 mbar repress' rule is lower than that of the values given according to the agency rules (because I have to guess my values sometimes) but my values have the advantage of being unbiased. In any case, I provide the values needed for ALL the different measurement rules so that the reader can pick their own.