Why do we sometimes forget the retrospective component of a particular task? I'm sure everyone experienced it quite a few times before. For example, sometimes when we go to the kitchen to grab something the moment we get to the kitchen you forget what you were trying to get. Why is that?
I must begin by stressing that while this is an interesting question, it is also very complex (much like memory itself). Similar to other areas of Cognitive Psychology, depending on which expert you ask, you might get different explanations. My background is in prospective memory and cognitive psychology, and this is how I would address this question. I believe this framing is crucial to contextualize my answer.
On a high level, we can classify memory into retrospective memory and prospective memory. Retrospective memory is where to be remembered item occured in the past (people, events, tacit skills). Prospective memory (PM) concerns how we remember to do things in the future (i.e., &quot;remembering to remember&quot;), or remember to perform an intended action at the correct time/situation. A classic example of PM is having to remember to pick up milk on the way home from work. Your ability to do this may be directed by active maintenance (e.g., reiterating to yourself for hours), self-generated cues/offloading (e.g., a phone reminder), or environmental cues (e.g., driving past the shop).
In prospective memory, it is common for individuals to remember to complete the prospective (e.g., go to the shop), but forget the retrospective component of the task (e.g., what to buy at the shop). This is the experience you are talking about. There is a wide literature of laboratory based experiments that attempt to explain the processes underlying why individuals sometimes forget to perform a PM task (see Smith et al.; or Brandimonte et al.; or Scullin et al.), or forget to perform the retrospective component (for review, see Mcbridge &amp; Workman).
Without getting deep into the neurological or exact cognitive level for why you would forget the retrospective component of a task, consider some factors that may decrease/increase probability of forgetting:

Task interruptions 'disrupting' your memory trace
A long duration between encoding an intention and having to retrieve the specific item from memory.
Pre-existing clinical disorder or ageing related disorder. Intoxication related brain function inhibition.
The to-be remembered retrospective component was unfamiliar, indistinct. You failed to encode the item properly in the first place.
Having a strong memory trace through implementation intentions can support memory for the retrospective component.
There's evidence that cue valence/salience (i.e., being positive/negative or distinct) or important improves  memory for the retrospective portion of PM.

That is but a small subset of possibilities. On a cognitive level, an activation based explanation would be that the &quot;to-be remembered retrospective memory item&quot; dropped below some critical threshold of neural activation, and was forgot. Interference based approaches would argue that some event during the retention interval disrupted the stored model or memory item, thus leading to forgetting. Neuropsychology based approaches would be able to map more specifically regions of the brain to forms of forgetting in laboratory based tasks.
In summary, we don't really know exactly why people forget things in any arbitrary context. However, psychologists can identify and classify the kind of forgetting that occurred, and provide suggestions of the likely factors that would have contributed to that forgetting. Neuropsychology approaches would assist in grounding these explanation in terms of neurological processes.
Further Reading:
Brandimonte, M. A., Einstein, G. O., &amp; McDaniel, M. A. (Eds.). (2014). Prospective memory: Theory and applications. Psychology Press. https://psycnet.apa.org/record/2002-02930-000
Smith, R. E., Hunt, R. R., &amp; Murray, A. E. (2017). Prospective memory in context: Moving through a familiar space. Journal of Experimental Psychology: Learning Memory and Cognition, 43(2), 189–204. https://doi.org/10.1037/xlm0000303
Burgess, P. W., Gonen-Yaacovi, G., &amp; Volle, E. (2011). Functional neuroimaging studies of prospective memory: What have we learnt so far? Neuropsychologia, 49(8), 2246–2257. https://doi.org/10.1016/j.neuropsychologia.2011.02.014
Schaper, P., &amp; Grundgeiger, T. (2018). The effect of different distractions on remembering delayed intentions. Memory, 26(2), 154–170. https://doi.org/10.1080/09658211.2017.1339090
Anderson, F. T., &amp; McDaniel, M. A. (2019). Retrieval in prospective memory: Multiple processes or just delay? Quarterly Journal of Experimental Psychology, 72(9), 2197–2207. https://doi.org/10.1177/1747021819845622
Ball, B. H., Brewer, G. A., Loft, S., &amp; Bowden, V. (2015). Uncovering continuous and transient monitoring profiles in event-based prospective memory. Psychonomic Bulletin &amp; Review, 22(2), 492–499. https://doi.org/10.3758/s13423-014-0700-8
Dismukes, R. K. (n.d.). Prospective Memory in Aviation and Everyday Settings. 22.
Heathcote, A., Loft, S., &amp; Remington, R. W. (2015). Slow down and remember to remember! A delay theory of prospective memory costs. Psychological Review, 122(2), 376–410. https://doi.org/10.1037/a0038952
Kuhlmann, B. G., &amp; Rummel, J. (2014). Context-specific prospective-memory processing: Evidence for flexible attention allocation adjustments after intention encoding. Memory &amp; Cognition, 42(6), 943–949. https://doi.org/10.3758/s13421-014-0405-2
McBride, D. M., &amp; Workman, R. A. (2017). Chapter Seven - Is Prospective Memory Unique? A Comparison of Prospective and Retrospective Memory. In B. H. Ross (Ed.), Psychology of Learning and Motivation (Vol. 67, pp. 213–238). Academic Press. https://doi.org/10.1016/bs.plm.2017.03.007
Scullin, M. K., McDaniel, M. A., &amp; Shelton, J. T. (2013). The Dynamic Multiprocess Framework: Evidence from Prospective Memory with Contextual Variability. Cognitive Psychology, 67(0). https://doi.org/10.1016/j.cogpsych.2013.07.001