PrepareApiAttributes is being fired for only one current discussion 50 times every boot
Number of times depends on count of posts being loaded during boot proccess.
If you look at the log when current discussion is being serialized you will see in one resource 22 merged resources. Each of them is current discussion with discussion_id=1.

You can see more details if you click the picture.
Call stack of Flarum\Tags event listener when it prepares discussion attributes. Dump aborted after a few repeats.

When document gets included posts each post adds current discussion because of relationship (line 77). Every time it is merged as a new resource.

No checks.

So each resource from 22 resources at line 171 is the same current discussion.

Altogether in the mentioned log PrepareApiAttributes was fired 50 times for the same discussion.
Note that during experiment it was a new copy of forum with only one discussion in it (discussion_id = 1).
I suppose that there is no need to repeat many times the same process.
Perhaps I do not understand the idea?