Q:

Different syntax for nodes with pos=x on a path with (A) -- (B) and (A) to (B)

I wonder why we need a different syntax for specifying nodes (and coordinates) on a path when using the simple -- and the .. controls … system or the to operation.
Here’s an example to illustrate the problem:
\documentclass{scrartcl} 

\usepackage[utf8]{inputenc} 
\usepackage[T1]{fontenc} 
\usepackage{tikz} 
\tikzset{every node/.style={fill=white,inner sep=2pt}}

\begin{document}
\begin{tikzpicture} 
    \draw [thick] (0,0) -- (5,2)
        node [pos=0.2] {A}
        node [midway] {B};
\end{tikzpicture}

\begin{tikzpicture} 
    \draw [thick] (0,0) .. controls +(1,2) and +(-2,-1) .. (5,2)
        node [pos=0.2] {A}
        node [midway] {B};
\end{tikzpicture}

\begin{tikzpicture}% with wrong result
    \draw[line width=1pt](0,0) to[out=40, in=160] (5,2)
        node [pos=0.2] {A}
        node [midway] {B};
\end{tikzpicture}

\begin{tikzpicture} 
    \draw[line width=1pt](0,0) to[out=40, in=160] 
        node [pos=0.2] {A}
        node [midway] {B} (5,2); 
\end{tikzpicture} 
\end{document}

When using -- or controls it is possible to position the node after the second coordinate.
  
But with to[in=x, out=y] this won’t work

all nodes go to (0,0) (not the first coordinate it’s always (0,0)) an we must gove the nodes before the second coordinate right after the to operation

I guess this has to do with the way to works but I wonder why …?

A:

The to path mechanism is extremely powerful.  Essentially, using a to path one can put anything on the path at the current stage in its construction.  When constructing a path segment, the to path machine needs to know the starting coordinate, the target, and any nodes to be placed on the path.  The latter is because the to path should have complete control, including deciding how to interpret the various ways of positioning a node on a path segment.
TikZ's path constructor works like a parser.  So it eats the input line, spewing out PGF commands as it goes along.  A to path constructor is invoked when the target coordinate is reached (but before it is processed).  Therefore any nodes that are to be involved in the to path construction have to be read before the target is specified.  It may be possible to specify nodes after the target, but whether or not this works will depend vastly on what the to path actually does.  In some simple cases, it simply inserts a more normal segment into the current path specification, in which case putting the nodes afterwards ought to work.  But if it does something more complicated then it will not.
With more simply path specifications, such as --, -|, or .. controls .., then TikZ knows how the path will look so when handling nodes it can be a little more flexible as to when they are specified: there's no potential for surprises.

