Probability of two sets of points occuring at a distance x along a line of length L Consider two sets of points : A and B.[ Number of points in A= a, Number of points in B=b].
A and B are randomly placed along a line of fixed length L. What is the probability of some A occuring next to some B at a distance less than x. (x is also a fixed length, x<L)?

 A: In the following, I assume that by “randomly placed” you mean independently randomly placed with a uniform distribution.
Also, I’ll be setting $L=1$; you can recover the results for general $L$ by substituting $\frac xL$ for $x$ everywhere.
I doubt you'll find a closed form for this for general $a$, $b$ and $x$, but cases with small $a$, $b$ or $x$ can be handled using inclusion–exclusion. Here I’ll show how to get an expansion in powers of $x$, but you can apply similar principles to small $a$ or $b$.
Let $E_{ij}$ be the event that the $i$-th point $A_i$ of $A$ and the $j$-th point $B_j$ of $B$ are within $x$ of each other. Then the probability that you’re looking for is
$$
\mathsf P\left(\bigcup_{ij}E_{ij}\right)=\sum_{ij}\mathsf P\left(E_{ij}\right)-\sum_{ijkl}\mathsf P\left(E_{ij}\cap E_{kl}\right)+\sum_{ijklmn}\mathsf P\left(E_{ij}\cap E_{kl}\cap E_{mn}\right)-\cdots\;,
$$
where the sums run over all unordered tuples of distinct pairs of indices.
The first sum is rather straightforward to calculate. Imagine the line closed into a loop – then the probability for $B_j$ to be within $x$ of $A_i$ is $2x$. But this includes cases where $A_i$ and $B_j$ are on opposite sides of the point where the loop was closed. This occurs with probability $x^2$, as you can see in this diagram (for $x=0.1$):

Thus we have $P\left(E_{ij}\right)=2x-x^2$, so
$$
\sum_{ij}P\left(E_{ij}\right)=ab\left(2x-x^2\right)\;.
$$
Since all remaining terms contain at least two factors of $x$, to first order in $x$ the desired probability is $2abx$. To get the result up to second order, we need to consider the second term in the inclusion–exclusion expansion. Here we just need the loop result, since the correction for the linear case contributes another factor of $x$.
There are $\frac{ab(ab-1)}2$ pairs of pairs of points, and for each of them, the probability that both pairs of points are within $x$ (in the loop) is $(2x)^2$. (Note that things become more complicated if we go to higher orders; for instance, quadruples of pairs of points can be of the form $(ij)$, $(kj)$, $(kl)$, $(il)$, and the probability that all four of these are within $x$ is not simply $(2x)^4$; in fact, it’s of order $x^3$.)
Putting it all together, we obtain the desired probability up to second order in $x$:
$$
\mathsf P\left(\bigcup_{ij}E_{ij}\right)=ab\left(2x-x^2\right)-2ab(ab-1)x^2+O\left(x^3\right)\;.
$$
For example, for $a=b=2$, this is
$$
\mathsf P\left(\bigcup_{ij}E_{ij}\right)=8x-28x^2+O\left(x^3\right)\;.
$$
Here’s a doubly logarithmic plot of the remainder $\mathsf P\left(\bigcup_{ij}E_{ij}\right)-\left(8x-28x^2\right)$, based on $10^8$ simulations using this code; the green line has slope $3$, which confirms that the remainder is of order $x^3$ and the second-order behaviour is correct:

