Can constipation be a learned behavior?

Yes. There has been and old relationship between constipation and psychological ( the anal phase of sigmund freud) issues. Constipation may be part of the irritable bowel syndrome. There are very obsessive pts. Overconscious of their bms that would not allow one day without moving their bowels using excessive use of laxatives creating a vicious cycle. Some use laxatives to reduce weight ( dangerouse).
Poor choice mistake. At some point, infants develop an awareness of a their readiness to empty & their option to hold it. Lacking the knowledge that they need to, their choice to hold it ( to avoid interrupting play) may alter this process.Stool retention leads to firmer, dryer stools that hurt when passing, which increases the desire to avoid stooling.Over time this stretches the colon walls which empty less effectively.