Are primes only defined for a specific set? When we are talking about primes, are they defined only in terms of the set/structure they belong to?
E.g. $3$ is a prime but $3= (\sqrt 7 - 2)(\sqrt 7 + 2)$ so it has factors but since they do not belong to $Z$ they are not considered as such and hence $3$ has only $1$ as a factor.
But is $3$ then considered composite for the set of real numbers?
Hence all the primes that we know in the realm of $Z$ are not really primes when moving up the set of numbers?
 A: Your notion of a prime (i.e. non-composite) is generally known as an irreducible, indecomposable, or atom, i.e. an element of an integral domain $R$ having only "trivial" factorizations $\color{#c00}{{\rm in}\ R},\,$ i.e. if $\,p = ab,\ a,b\,\ \color{#c00}{{\rm in}\ R},\,$ then one factor is trivial (i.e. $1$ or a divisor of $1$, i.e. a unit = invertible $\color{#c00}{{\rm in}\ R}).\,$ Further atoms are assumed to be nonunits $\color{#c00}{{\rm in}\ R}.$ This definition does depend on the $\rm\color{#c00}{underlying}$ $\color{#c00}{\rm ring}$ since said factorizations and divisibilities depend on the multiplication table $\color{#c00}{{\rm of}\ R}$.
In particular, an atom $\,p\,$ need not remain an atom in an extension ring because its multiplication table may differ on such matters, e.g. we can always adjoin $\sqrt p$ to $R$ get a nontrivial factorization $\,p = \sqrt{p}\sqrt p\,$ by extending to $\,\bar R = R[x]/(x^2-p),\,$ i.e. $\,R[x]\bmod (x^2-p).\,$ In this quotient ring we have $\,p \equiv x^2\,$ and this factorization is nontrivial, i.e. $x$ is a nonunit in $\bar R,\,$ for otherwise $\, 1 \equiv x f(x)\pmod{\!x^2-p}$ for some $\,f\in R[x]\,$  so $\, 1 = xf(x) + (x^2-p) g(x),\,$ so evaluation at $\,x=0\,$ yields $\, 1= -p\:\!g(0)\,$ in $R$, so $\,p\mid 1\,$ in $R$, contra $p$ is an atom in $R$ so not a unit in $R$.
$p$ can also fail to persist as an atom in an extension ring if it becomes a unit, e.g. we can adjoin its inverse by passing to $R[x]/(px\!-\!1);\,$ e.g. as you note, $3$ becomes a unit when extending $\Bbb Z$ to $\Bbb R$.
Like atoms, by convention composites (nonatoms) are also usually assumed to be nonunits, so above the unit $3\in\Bbb R$ is neither an atom nor a composite.
A: (In more abstract contexts, the ones that you refer as "primes" are called "irreducible" elements).
You can define irreducible elements and divisibility in any set $S$ equipped with a binary operation $(S,\cdot)$ that satisfies the following properties:
1)Associative property.
2)Commutative property.
3)There is an identy element $1$.
4)$sk=sh\Rightarrow k=h$   (each element is cancellable)
This algebraic structure is called a commutative regular monoid.
In this setting you can say that given two elements $s_1,s_2 \in S$, $s_1$ divides $s_2$ if and only if there is a $k\in S$ such that:
$$s_2=ks_1=s_1k$$
(Notice that $ks_1=s_1k$ because of the commutativity of $\cdot$, otherwise you have to define divisibility on the left and on the right as two separate concepts).
An element $i\in S$ is called irreducible if and only if:

*

*Its only divisors are invertible elements and elements of the form $ui$ where $u$ is invertible.

*It's not invertible.

The first conditions is stated in this way because those divisors are unavoidable!
In fact:
$$i=(iu^{-1})u=(iu)u^{-1}$$
So we can't forbid divisors of this type. The second condition is stated as this because invertible elements have trivial divisibility properties(they divide any other element amd their only divisors are invertible elements), so it's not meaningful to talk about them.
Usually you use the word "irreducible" because "prime" has another meaning. In fact an element $p\in S$ is prime if and only if (it's not invertible and) when $p$ divides a product of two elements, it divides at least one of them(the intuitive meaning is that $p$ is an indivisible multiplicative block, so if it divides a products of two "buildings" it divides one of them and can't be splitted between the 2).
In general prime elements and irreducible elements are different concepts, but they coincide if in $(S,\cdot)$ each element has an "unique" factorization(for example they coincide in $\mathbb{Z}-\{0\},\mathbb{N}$).
In your case $(\mathbb{R}-\{0\},\cdot)$ is an abelian group so every element is invertible and no element is prime or irreducible.
In the comments they wrote about rings, and in fact usually these things are defined in rings(because having also a sum $+$ makes the structure richer in some sense, and allows to prove more things, even if it's not strictly necessary).
A: I think you are right, even though the nomenclature you used is wrong. The concept of a prime is first taught to us (and was first defined) for natural numbers, so the common definition of prime only considers factorisations in natural numbers, however this concept of factorising a number is not exclusive for natural, whole or rational numbers. In any set with some analogue multiplication you could define it. This is why it is more generally defined for rings.
Rings are algebraic structures that consist of a set with addition and multiplication such that addition is commutative has identity and has inverses (you can "subtract" and have a 0). Also you have to have the associative law and sometimes multiplication has an identity (an analogue to number 1, since it "does nothing"). Examples of rings can be the integers, rationals, reals and even other sets such as that of matrices with real entries. As we can see with the last example multiplication need not be commutative, but for simplicity lets assume it is, if you are interested in looking at the non-commutative case there are plenty of texts treating non-commutative rings. In rings you can also define a prime, and it is usually done in the following way.
A prime in a ring $R$ is an element $p$ of  this ring such that if $ab=pk$ then $a=fp$ or $b=sp$.
In other words, if $ab$ is a multiple of $p$, then either $a$ is a multiple of $p$ or $b$ is a multiple of p.
In the integers this definition is the same as that of a regular prime. If we allow a ring such as the integers to have more elements then elements that were prime can stop being so. You gave one example with $\sqrt{7}$, if we allow to add, subtract and multiply this number in conjunction with all the integers we say we "adjoin" this element, since it wasnt there before, and we indeed "lose" some primes. Sometimes you even loose unique factorisation.
In summary, answering your question it is true our "everyday primes" stop being so in other situations such as the rationals or reals. In fact, in these two cases in fact none of the original primes remain primes, and 0, which wasn't a prime in the integers, becomes a prime (the only prime) in the rational, real and complex numbers. This is because they are fields, a special kind of ring.
All of this has been explained quite informally, if you are interested in the topic you can read other basic texts on rings in which everything will come with much more rigour, however if you haven't done any abstract algebra before better start with a basic book on that, which will probably explain the basics of this too.
