Spanning tree of a rectangular grid
K (ngn/k), 8 bytes

|\'2'+!:


Try it online!

this is a composition equivalent to the lambda {|\'2'+!x}. the trailing : forces ! (and therefore the whole composition) to be monadic.

 !2 3         /odometer
(0 0 0 1 1 1
 0 1 2 0 1 2)
 +!2 3        /flip
(0 0
 0 1
 0 2
 1 0
 1 1
 1 2)
 2'+!2 3      /pairs (sliding window size 2)
((0 0;0 1)
 (0 1;0 2)
 (0 2;1 0)
 (1 0;1 1)
 (1 1;1 2))
 |\'2'+!2 3   /cumulative(\) max(|) each(')
((0 0;0 1)
 (0 1;0 2)
 (0 2;1 2)
 (1 0;1 1)
 (1 1;1 2))