I can't say "invented" because, as to James's death, Earl Doherty is open to the possibility that his legend has a historical nucleus, James being a Christian who probably didn't know about an earthly Jesus (the first gospel was not yet written when Hegesippus reported the legend of James).
As to John the Baptist, I follow Rivka Nir who argues for Origen quoting Hegesippus, an not at all Josephus, about him.
But what moved Hegesippus to report legends in a written form, under the name of Josephus (coincidentially or deliberately)?
Afterall, the earthly Jesus was not yet invented, by the time Hegesippus wrote.
I think that the reason of the interpolation is the growing interest by pre-Gospel post-70 Christians to introduce stories and/or legends about the death of Christian preachers (James and John being examples of Christian preachers, yes, John too), as precursors of the collective 'death' of the nation of Israel in 70 CE.
Note that in the same gospel of Mark, the reader is assumed to know that the both two sons of Zebedee, James and John, will receive martyrdom (the irony being that even their martyrdom was not sufficient to give them the first places, Paul and possibly Marcion being better candidates, or the two crucified thieves).
In conclusion, I see these legends as "technical tests" of legends connecting the death of Christian leaders with the national tragedy.
This say us that it is not a coincidence that the choice was fallen just on James and John, the predicted martyrs according to Mark.
So the miracle happened that the death of the Pillar John was confused with the death of John the Baptist. The confusion was forced, i.e. the paulinist "Mark" deliberatey doubled the historical John the Pillar in two figures: John son of Zebedee and John the Baptist. Why? Because John the Pillar was probably riotously anti-pauline: the "good" John the Pillar became the pre-Christian John the Baptist, while the "evil" John the Pillar became the John son of Zebedee.
The latter saw Paul as a not Christian:
“Do not stop him,” Jesus said. “For no one who does a miracle in my name can in the next moment say anything bad about me, for whoever is not against us is for us.
(Mark 9:38-40)
The Paulinist didn't forgive the attack: John the Baptist and his disciples were considered as not-Christians.
Obviously, everything I have said here is true even if I assume Marcion as author of the first gospel.