How to remove extra space between figures, tables, links and captions?

Hello,
I noticed that when a capture follows a table, figure, link or a code snippet, the space is larger between those elements, in comparison to a caption following a text. Why is that and how can the “extra space” be removed?
Thanks and kind regards

Do you have any code that can produce an example? I must be misunderstanding the problem, because the vertical spacing following these two figure types is the same:

#set align(center + bottom)

#let text-fig = box[
  #figure(
    [text figure],
    caption: [caption]
  )
  Following Text
]

#let table-fig = {
  set text(red)
  box[
    #figure(
    table([table figure]),
    caption: [caption]
    )
    Following Text
  ]
}

#grid(
  columns: 2,
  column-gutter: -6.7em,//Overlap them to make differences more obvious
  table-fig,
  text-fig,
)


Hi. You can modify figure.gap. The other space is par.spacing.

#set par(spacing: 0pt)
#set figure(gap: 2em)
#figure(table[], caption: [Caption])
#lorem(50)