logand is a binary operation. It will return the value of the bits that test true for both (or how many ever integers) you pass as arguments. I will explain with 2 simple numbers
6 - expressed in binary is 0 0 0 0 0 1 1 0
13 - expressed in binary is 0 0 0 0 1 1 0 1
Result - 0 0 0 0 0 1 0 0 (value 4)
log and will test where 1 is matching in both numbers, so the result will be 3rd bit tested true and so value is 4 [ 1st bit 2 to power 0 - 1, 2nd bit 2 to power 1 - 2, 3rd bit 2 to power 2 - 4]
Say we use 6 and 15
6 - expressed in binary is 0 0 0 0 0 1 1 0
15 - expressed in binary is 0 0 0 0 1 1 1 1
Result - 0 0 0 0 0 1 1 0 (value 6)
Ggoing back to your original query of logand in LeeMac code undoctl has following values
0 UNDO is turned off
1 UNDO is turned on
2 Only one command can be undone
4 Auto is turned on
8 A group is currently active
16 Zoom and pan operations are grouped as a single action
32 Layer property operations are grouped as a single action
Different combination of the above can be true at any given time, so for instance if 8 and 16 are active together then the value is 24. Similarly if 8 and 4 are active then the value is 12. Irrespective of the combination logand will verify if bit 3 is activated (value 8)
You can test different combinations from the above 7 values [0, 1, 2, 4, 8, 16, 32] to verify that anytime 8 is factored in then (= 8 (logand 8 (getvar 'undoctl))) will return T otherwise nil
Command: (logand 8 0); UNDO turned off
0
Command: (logand 8 12); 8 and 4 value activated
8
Command: (logand 8 24); 8 and 16 activated
8
Command: (logand 8 61); all activated except value 2
8
Command: (logand 8 63); all activated
8
Command: (logand 8 55); all activated except 8
0
The above are just for example purposes; under what settings they will be true is a different question. To answer in short, the code (= 8 (logand 8 (getvar 'undoctl))) is testing if bit 3 is activated (value 8) and returning T so that vla-endundomark can be called