To add to @Cardinal 's answers in the comments, I think there is work that addresses the "claim the null distribution of the Kolmogorov-Smirnov maps onto another lattice path problem that could be solved by a "two-sided ballot theorem" and "is there a general framework around all of this? The two-sample KS test?":
This paper (preprint) is concerned with r-sample Kolmogorov-Smirnov tests and they derive the exact null distribution by counting lattice paths by using a generalization of the classical reflection principle. In Section 2, I find that they lay out nicely how lattice path counting comes into play when deriving the null hypothesis.
In the introduction the paper also features a discussion on how lattice path counting and the reflection principle tie in here by reviewing ideas started with Kiefer 1959 and David 1958. They also briefly discuss how it can be seen as an r-ballot counting problem, referring to Filaseta 1985.
They provide a lattice path counting framework for KS type tests for any number of samples. From the paper:
We consider the problem of testing whether $r ≥ 2$ samples are drawn
from the same continuous distribution $F(x)$. As a test statistic we
will use the circular differences $\delta_r (n) = \max [\delta_{1,2}
> (n), \delta_{2,3} (n), . . . , \delta_{r−1,r} (n), \delta_{r,1} (n)],$
where $\delta_{ij} (n) = \sup_x [F_{n,i} (x) − F_{n,j} (x)]$, and
$F_{n,i} (x), i = 1, 2, . . . , r$ denote the empirical distribution
functions of these samples. We derive the null distribution of
$\delta_r(n)$ by considering lattice paths in $r$-dimensional space
with standard steps in the positive direction, i.e., steps are given
by the unit vectors $e_i , i = 1, 2, . . . , r$. By a simple
transformation we show that for some positive integer $k$ the number
of ways the event $\{n\delta_r (n) < k\}$ can occur is just the number
of paths $X$ with the property that for each point $X_m$ on the path
there holds the chain of inequalities $x_{1,m} > x_{2,m} > . . . >
> x_{r,m} > x_{1,m − rk}$. Indeed, the enumeration of such paths is a
well studied problem in combinatorics. Again the reflection principle
comes into play as we have to count paths in alcoves of affine (and
therefore infinite) Weyl groups; for references on the technical
background of this topic see Gessel and Zeilberger 1992,
Grabiner 2002 and Krattenthaler 2007.
Hopefully this is a good starting point for further investigations into the Kuiper and AD statistics for example.