This shows up in one of the compiled functions in tests.model.marginal.test_one_to_many_unaligned_marginalized_rvs.
There are two scenarios that can happen:
This rewrite should be triggered https://github.com/pymc-devs/pytensor/blob/1d5b1d94131d4c2e3fb4b9cd18771f8ade046a51/pytensor/tensor/rewriting/blockwise.py#L215-L234 and jumping into it in interactive debugger and see why it doesn't apply will answer the question in this issue