It is possible to trade emeralds with the Villagers only on their adult individuals, but it turns out that the cubs are also quite capable of trading. How to reproduce:
Get the command block, install it and enter the command in it: /data merge entity @e[type=minecraft:villager,limit=1] {Age:-24000}
Build a timer on repeaters in the amount of eight pieces (or more) and set the maximum delay on them.
Put a button next to the first repeater.
Summon a Villager by following the command: /summon minecraft:villager
To get any profession, quickly put any work block where the Villager is by running the command: /setblock ~ ~ ~ minecraft:smithing_table
Give yourself more emeralds by following the command: /give @s minecraft:emerald 64
Click on the button, thereby starting the timer on the repeaters and quickly open the trading window with the Villager.
After the timer on the repeaters ends and the command block changes the height of the Villager, making him a cub, you will not automatically exit the window of trading with the Villager, but everything will continue and you will be able to trade with him further, and the cub of the Villager will make joyful sounds and show various items suitable for the profession of the Villager.
Thank you for helping us improve Minecraft! We saved your files: