When to use electrical tape rather than wire nuts?
I tend to agree with the comments


This is an inline splice
Whomever did this was covering solder


So, having said that...

Electrical tape is good for insulating wire. It cannot hold wires together. In this case, the solder is holding the wires, but I really wouldn't trust solder for electrical wires. Wires can get warmer when in use, which could weaken or break the solder.

Wire nuts involves twisting the wires together, meaning the wires hold themselves in position, The nut insulates the top and helps (somewhat) stop movement.

I would only use electrical tape on a wire that has had its insulation damaged.