What is the correct pinyin for 哪儿? I've seen both Nǎ'er and Nǎr.

The first form looks more like a literal transcription of each character, while the second one  might be the way it's pronounced (assuming there is a difference)

I do understand pinyin is just a learning / transliteration tool; I'm more interested in the explanation of the cases where this conversion is applied and why.
儿 in this case indicates the application of 儿化 (er2hua4) or 'r-coloring' to the previous syllable.

To input 哪儿 using a typical Pinyin IME, you would have to type naer or na'er, because nar would be segmented na r, and the IME would then expect further input for a second Pinyin syllable beginning with r.

Outside of keyboard input, however, the correct Pinyin for 哪儿 is nǎr, because 儿 is not being used to represent a full syllable. Where it represents a full syllable, it would be represented as ér in Pinyin.