Try this:
set interfaces ae31 flexible-vlan-tagging set interfaces ae31 mtu 9216 set interfaces ae31 encapsulation extended-vlan-bridge set interfaces ae31 unit 3174 vlan-tags outer 3174 set interfaces ae31 unit 3174 vlan-tags inner-range 21-22 set interfaces ae31 unit 3174 input-vlan-map push set interfaces ae31 unit 3174 output-vlan-map pop
Question: Why do you need to create vlan 21? Either QinQ or single-tag in your case.