This is a very basic question but I seem not to get a "simple" definition anywhere that is at the same time rigorous and clear. I probably understand basic definitions of topology, topological spaces, open and closed sets, manifolds etc. However, I fail to see what compact or closed topological spaces and manifolds are.
I realise that there is a difference between these concepts as applied to topological spaces and manifolds. Also, how do we define the boundary of a topological space and a manifold?
I frequently have to encounter these concepts while studying gravity and a clear intuitive picture would help a lot.
Let me try to give you some intuition. A (topological) manifold is a topological space that locally looks like $\mathbb{R}^n$ for some fixed $n \geq 0$. An easy example of a $2$-manifold would be the "globe" $S^2$. If you zoom in on the globe it looks flat and like a plane (which is why we use maps on sheets of paper to describe things on the globe). So locally it behaves like $\mathbb{R}^2$. For the formal defintion we need to understand what it means to behave like another space.
$\textbf{Definition 1.}$ Let $X$ and $Y$ be topological spaces. A continuous map $f \colon X \rightarrow Y$ is called homeomorphism if there exists a continuous map $g \colon Y \rightarrow X$ such that $g \circ f = \text{id}_X$ and $f \circ g = \text{id}_Y$.
Now we could define manifolds by just using that notion, but usually one wants to exclude some rather stupid examples (pathologies) to get a nice theory. Therefore we have two additional axioms that ensure that manifolds behave nicely. We want to be able to distinguish points by using elements of the topology. For example we can separate points in $\mathbb{R^n}$ by $n$-dimensional balls surrounding them. There are several separation axioms, but a very convenient and not too restrictive one is the following:
$\textbf{Definition 2.}$ A topological space $X$ is called Hausdorff if for each pair of points $x,y \in X$ there exist open disjoint sets $U,V \subset X$ such that $x \in U$ and $y \in V$.
One could maybe expect that we would get the Hausdorff property for free if $X$ is a space that is locally homeomorphic to $\mathbb{R}^n$, but that is actually not the case. A counterexample is for example given by the real line with two origins.
The last ingredient to define manifolds is given by:
$\textbf{Definition 3.}$ A topological space $X$ is second-countable if it has a countable basis for the topology.
This property ensures that we can embed manifolds into $\mathbb{R}^m$ for some $m \geq 0$ (at least given some additional property like compactness).
$\textbf{Definition 4.}$ Let $n \geq 0$. A second-countable Hausdorff space $X$ is called $n$-manifold if every point $x \in X$ has a open neighborhood $U \subset X$ that is homeomorphic to some open set $V \subset \mathbb{R}^n$.
Given a manifold $X$ one can show that there always exists a countable basis of $X$ which is homeomorphic to $\mathbb{R}^n$ itself. So we can also require that instead.
Let me now adress your questions.
Your question: "Closed and compact things":
By definition of a topology, the space itself is always closed. Therefore it does not really make too much sense to speak of a closed topological space without some extra context. Usually, the context would be that the space you want to consider is a subset of another topological space and therefore is not necessarily open or closed purely by definition of the topology.
Now there is the notion of closed manifolds, which requires the notion of compactness. Compactness is a finiteness property that allows to control spaces a lot more and also enables certain classifications of small-dimensional manifolds as well.
$\textbf{Definition 5.}$ Let $X$ be a topological space. We say that $X$ is compact if every open cover $X = \bigcup U_i$, $i \in I$, has a finite open subcover, that is $X = U_{i_1} \cup \dots \cup U_{i_r}$ for some $i_1,\dots,i_r \in I$.
That just means that whenever we can cover our space $X$ by open sets, we actually only need finitely many of these open sets. This is a property that for example does not hold for $\mathbb{R}^n$ (at least if $n \geq 1$). Now I can give you the desired definition.
$\textbf{Definition 6.}$ A compact manifold (without boundary) is called a closed manifold.
Now the definition of manifolds that I have given is for manifolds without boundary, such that you actually don't really need to study manifolds with boundary if you only want to get a feeling for closed manifolds. For manifolds with boundary one does not require that the space $X$ locally "behaves" like $\mathbb{R^n}$ but like $\lbrace (x_1,\dots,x_n) \in \mathbb{R}^n \mid x_n \geq 0 \rbrace$. You can for example consider the open unit Ball $B_{<1}(0)$ with radius $1$ and the closed unit ball $B_{\leq1}(0)$ to get examples of (non-compact) manifolds without and with boundary. The boundary of the latter is just the intuitive boundary.