Anxiety and sleep
It can be. Anxiety
is generally caused by worried thinking and to fall asleep it is necessary for the mind to unwind and calm enough for sleep
Find what works for you to help this process of unwinding/calming your mind before sleep. Reading a comforting book, taking a bath, listening to soothing sounds or music, learning to meditate, are examples. Medication is a last resort.