How to establish a collaboration with other researcher?
It is generally good to be explicit about your expectations. You don't want to end up in a situation where one person thinks it is her/his project and the other person has a well deserved place in the "thank you section", while the other person thinks she/he deserves to be a co-author. Such a conflict is really bad for everybody involved.

So when I propose a collaboration or someone comes to me with a proposal, I will discuss co-authorship from the beginning. This makes the discussion less informal than you suggest in the question. 

It may still happen (and it has happened to me) that someone comes for advise, and I give that advise under the assumption that I am not a co-author, and the original author is so happy with the advise that I end up being "upgraded" as author. 

Similarly, but more tricky, it may happen that I am "downgraded" when my contribution is not significant enough to warrant authorship. Maybe because I did not invest enough time in it, or the sub-problem I am supposed to tackle turned out to be less relevant to the entire project than originally expected. The tricky part is that ideally the downgraded person has to agree otherwise we are in a conflict of the type we were trying to avoid.