Dicts, attribute variables and cyclic terms

Fine, but what is this expected to do? Do you expect L2 to hold [1,2]? Or maybe [#{a:1}.a, #{a:2}.a]? In any case, the first argument of bagof/3 is not a meta argument
and this is thus equivalent to this body, clearly resulting in an instantiation error.

     L = [ #{a:1}, #{a:2}],
     Tmp = M.a,
     bagof(Tmp, member(M, L), L2)

What works is

t(L2) :-
    L = [ #{a:1}, #{a:2}],
    bagof(X, (member(M, L), X = M.a), L2).

My advice is to avoid functional notation when meta-predicates are involved. The rule is that the system will apply goal expansion to the meta-argument.