Language of words that begin and end with same symbol and have equal numbers of a's and b's
Here is the thought process I would use.  I would notice that your language $L$ can be written as $L= L_1 \cap L_2$, where $L_1$ is the set of words that begin and end with the same symbol, and $L_2$ is the set of words that have equal quantities of a's and b's.

Then, I would note that $L_1$ is regular and so can be expressed by a simple DFA (with 5 states).  Also, I would note that $L_2$ is context-free and can be expressed by a simple CFG: e.g., $S \to \varepsilon \mid aSb \mid bSa \mid SS$.

Finally, I would recall the standard closure property: the intersection of a regular language and a context-free language is context-free.  It follows that $L_2$.  The proof of this standard closure property includes a construction that shows how to construct a CFG for $L_2$, given a DFA for $L_1$ and a CFG for $L_2$.  This gives a CFG for your language.  The resulting CFG will have $5^2=25$ non-terminals; some of them are unreachable and can be pruned, but the result is still quite messy.

The resulting CFG isn't the simplest or smallest CFG for your language.  Whether it is the most natural is open for debate.  But since you asked for the thought process behind coming up with a grammar, this illustrates one general technique for constructing CFG's: separate out the part that requires something more than finite state (equal quantities of a's and b's) from the part that can be handled with a finite-state automaton.