Hi there JulieMarie,
Welcome to SI. You are at the start of a very long road but with a lot of effort and a willingness to deal with some very uncomfortable feelings you can survive infidelity.
Most everyone here has been exactly where you are. We chose to betray the people we said we cared about most for the sake of feeling better about ourselves. Our betrayed spouses found out either because we confessed or someone else told them or they discovered evidence on their own. Which one was it for you?
Right now you are most likely in panic mode and are grasping for what to do to fix this. Know that neither your marriage nor you can be healed in a day, a month, or even a year. Infidelity is a life changing event. Your relationship will never be the same but that does not mean that it can't be repaired. It will be up to your guy if he is even willing to try. Infidelity might be a dealbreaker for him. If he is willing to try reconciling with you it will take a phenomenal amount of work from you and you will have to work on fixing yourself while he is going through an emotional hurricane. Still, many people here have navigated the path to healing and can help you along the way.
A good place to start is the post "Things every WS needs to know" by HUFI PUFI. I'll bump it up to the top for you. The Healing Library mostly addresses betrayed spouses but it is a great resource for starting to understand what your guy is going through.
A couple of other questions for you.
Is the affair COMPLETELY over? Are you still in contact with the affair partner in any way?
Does your guy know about your betrayal?
Does your guy know ALL of it? Is there anything else you are hiding?
The thing that most kills chances for reconciliation is continued lying after discovery. During the affair you did a lot of lying. Now is the time to stop that. No minimizing, no spinning, no shading the truth so that you don't come out looking so horrible. The phrases "only for maybe 6 months" and "ONE encounter" are examples of that.
Eventually you will need to understand why you did this. The "why" you stated in your post is very surface. You're going to need to dig down deeper. Once you identify the specific brain wiring that made you think it was okay to get your need to feel attractive met at your betrayed partner's very great expense you're going to have to figure out how to fix that wiring and replace those thought processes with something else that won't put your partner at risk of betrayal the next time you feel crummy about yourself. It's the only way you can ever be a safe partner for him and frankly for yourself.
Stick around, post, and buckle up. It's a rough ride but I can tell you that doing the work is worth it whether your relationship survives or not.
Welcome to the path from a fellow EvolvingSoul.