This is kind of hard to get them because items or blocks don't belong to tags, but tags belong to them : basically, an item (or a block) has a list of tags associated to it.
Luckily, there's another way to get the tag rather than looping through every item in the game and check if it has the tag you want :
// This is to get the values of a tag that is bound to items :
ForgeRegistries.ITEMS.tags().getTag([THE TAG YOU WANT]).stream().toList(); // Returns a List<Item>
// ^
// Should be a TagKey<Item>
// To get a tag that is bound to blocks :
ForgeRegistries.BLOCKS.tags().getTag([THE TAG YOU WANT]).stream().toList(); // Returns a List<Block>
// ^
// Should be a TagKey<Block>
Hope it helps