This is very common for male bettas to do Ploaker. They do not just do it when breeding, but when they are happy and comfortable in their environment. It's instinct, not something they 'learn'.
Further to this, and speaking (as usual) as one who knows nothing:
as with many other reassuringly familiar behaviours, it seems bubblenesting also may be reverted to by bettas in moments of stress or boredom.
One of my super deltas absolutely freaked when I first added Ramshorns to his tank.
He'd rush round, flaring at one and then another, and struck at one, becoming ever more agitated - then ultimately went to frantically start bubblenesting, with breaks for more aggressive flaring.
The behaviour gradually abated, but it did strongly appear to be related to stress as well as an attempt at establishing territory as his own...
I just felt this was interesting, if hardly unusual on a more universal behavioural basis, as generally not remarked upon in bettas.
Perhaps we should all collaborate on a soon-to-be-bestselling 'Psychology of the Betta Fish'?
Careful not to allocate a human behavior to a betta fish though.
Boredom is certainly not a reason for a betta to bubblenest... Unless you are getting at repetitive behaviors and psychology behind it, which still would not apply to a fish in terms of a boredom context. There are easy ways to describe animal behavior by using human emotions/actions as a comparison, but I do not think boredom applies for this instance.
However, "stress" (or what i think you meant as more of a dominance display) is certainly another reason for a betta to bubblenest. For example, my bettas in a divided tank constantly built nests to out-compete each other. My betta that had stopped building nests entirely for months started again when given 'a reason' (another male betta that could potentially win over a female). The bubblnest building got to extremes in this tank... it was quite funny to watch. As it applies to your SD and the Ramshorns: exactly as you said, territory. He saw competition and reverted to an instinctive dominance display. Unfortunately, in a small tank, these behaviors do not usually occur as they would in nature, and many different things can be observed as a result of this.
Stress in the real sense would cause a betta to hide and clamp their fins.
Anyways, you certainly brought up another point/reason why bettas build bubblenests that was not mentioned

. guess i was just jabbering for the hell of it.
Start compiling posts and we will have
Betta Section of Tropical Fish Forums Presents.......
Psychology of Betta Fish
edit:
thought i would throw in a pic of what i was referring to with hilarious bubblenesting. didn't take long for the other guy to 'make' a rebuttal
apologies for the people that have seen me post this pic multiple times. it just makes me laugh when i read 'bubblnest' topics and remember this monstrosity of a nest.
edit 2 (just for the sake of settling potential curiosity.... yeah... that's it)

. The two culprits behind that nest:
yes, real size difference
ok. im done blatantly veering off topic and thread hijacking. just couldn't help it seeing the other pics while i was searching through old times in my imageshack account

. Ploaker, i hope this was more of an informative/entertaining post than an annoyance.

at myself. No mas cerveza