Claim 1: Let $X,Y$ be positive integers with $Y>1$ and $Z=X/Y$. If there is a factor $B$ of $Y$ such that $B<Y$ and $Z\cdot B=A$ for some factor $A$ of $X$, then $X$ shares a factor with $Y$ other than $1$. If no such $B$ exists, then $X$ and $Y$ are relatively prime.
Proof: Suppose there is a factor $B$ of $Y$ such that $B<Y$ and $Z \cdot B=A$ for some factor $A$ of $X$. Then $(X/Y)\cdot B = A$, so $X= A\cdot (Y/B)$. Note that $Y/B$ is an integer and is greater than $1$, since $B$ is a factor of $Y$ and $B<Y$. So $Y/B$ is a factor of $X$ and a factor of $Y$ which is not $1$.
If no such $B$ exists, let $D=\gcd(X,Y)$ be the greatest common divisor of $X$ and $Y$. We can write $X=D\cdot M$ and $Y=D \cdot N$ for some integers $M$ and $N$ which do not share any factors greater than $1$. Then $Z=X/Y=(D\cdot M)/(D \cdot N)= M/N$. Now $N$ is a factor of $Y$. If $N<Y$, then $N \cdot Z$ is not a factor of $X$ (by assumption). That is, $N \cdot M/N=M$ is not a factor of $X$. Yet $X=D \cdot M$, so $M$ is a factor of $X$. So it must be that in fact $N=Y$ Then $D=1$. Finally, $\gcd(X,Y)=1$ if and only if $X$ and $Y$ are relatively prime.
Claim 2: Suppose for some $1<Y<X$, there exists a factor $B$ of $Y$ such that $B<Y$, and $Z \cdot B = A$ for some factor of $A$, where $Z=X/Y$. Then $X$ is composite. Otherwise, if no such $Y$ exists, $X$ is prime.
Proof: If such a $Y$ exists, then by Claim 1, $X$ and $Y$ share a factor greater than $1$. In particular, they share a prime factor $P$. Then $P \leq Y<X$, so $P$ is a prime divisor of $X$ not equal to $X$, and thus $X$ is composite. If no such $Y$ exists, then by Claim 1, $X$ is relatively prime to every $Y$ such that $1<Y<X$. In particular, $X$ is relatively prime to every prime less than $X$. Being relatively prime to a prime number means precisely that $X$ is not divisible by that prime. So the only possible factors of $X$ are $1$ and $X$, so $X$ is prime.
Ultimately your property of there being a factor of $Y$ less than $Y$ such that $X/Y$ times that factor is a factor of $X$ boils down to saying the $\gcd$ of $X$ and $Y$ is greater than $1$. This is because if $D=\gcd(X,Y)>1$, I can write $X=D\cdot M$ and $Y=D\cdot N$, and choose $N$ to be the factor of $Y$. So you have stumbled upon the fact that if $X$ is relatively prime to everything less than $X$, then $X$ must be prime. Hopefully this shows you why $\gcd$'s are so useful in elementary number theory!