Marginal distribution for a set of discrete events in continuous time

Assume we have a set of four events $\{(k_1,t_1),...,(k_4,t_4)\}$ where the $k_i$ label the type of event from a finite set of possible events, and the $t_i$ their respective times, with $t_i < t_{i+1}$. Let us define $P(\{(k_1,t_1),...,(k_4,t_4)\})$ as the probability of this set of events happening within intervals $dt_i$ around the times $t_i$. Now we would like to know the marginal distribution of only the first and fourth event which should be $$P(\{(k_1,t_1),(k_4,t_4)\}) = \sum_{k_2,k_3}\int_{t_1}^{t_3}dt_2\int_{t_2}^{t_4}dt_3 P(\{(k_1,t_1),...,(k_4,t_4)\}).$$ The sums are fine, but the integrals seem problematic due to their limits. We know the first event happens before the second one, so $t_1$ is the lower limit for the $t_2$ integral. That's fine. But similarly since we know the third event happens after the second, $t_3$ is the upper limit of that integral. But for the same reason $t_2$ is also the lower limit for the $t_3$ integral. So we have a double integral where one of the limits of the first integral is the integration variable of the second integral and vice versa.

If on the other hand we were looking for say $P(\{(k_1,t_1),(k_3,t_3)\})$ this should be much more straight forward since each marginalised event is separated by a non-marginalised event, so the integration limits are well defined.

Is there something wrong with the definition of this marginal? If not, how can such an integral be evaluated?

The double integral is nested, and you cannot "separate" them. Since $t_1 < t_2 < t_3 < t_4$, to obtain the joint pdf of $(t_1, t_4)$, we can integrate by
$$\int_{t_1}^{t_4}\int_{t_2}^{t_4} f(t_1, t_2, t_3, t_4) dt_3dt_2 = \int_{t_1}^{t_4}\int_{t_1}^{t_3} f(t_1, t_2, t_3, t_4) dt_2dt_3$$
So the limits depends on the order of integration. If you integrate with respect to $t_3$ first, then the "tightest" bound would be $(t_2, t_4)$, and after $t_3$ is integrated out, the remaining bound for $t_2$ will be $(t_1, t_4)$.