It's an easy mistake to make: creating characters too much like you. As you develop in writing, you learn to build a more various cast and include some personality contrast. We're still writing from within our own experience, though, and unless we notice that our experience isn't universal, we just keep on replicating it. I only discovered recently that most people don't see music - so I have to comb back through my novel, checking that my characters aren't all synaesthetic. I'd just assumed that everyone sees the world as I do, including the music. An issue like that can just be idiosyncratic. When it comes to the experience and assumptions of our various identity positions, though, that matters more. We think we're writing a varied cast, but actually every character looks like us.
Have a quick flip through your characters - the main characters, the secondary characters, the walk-ons and extras. If you are white, straight, and cis (ie you identify with your physical gender at birth), are all your characters also white, straight, and cis? In other words, do they basically all look like you?
Identity positions is too large a subject to cover off neatly in a blog post, but here's a thumbnail sketch: some of the main identity positions are male / female, straight / gay / bi, cis / trans, white / other races. In each of those, one of the positions has "privilege": it's assumed to be the norm and is socially seen as higher status. (I'm glossing fast, here, so forgive the lack of nuance.) When you have a privilege, it's easy to be blind to it: as a white person, I don't need to notice my race, because it's rarely an issue. That blindness means you assume your experience is universal (when it absolutely isn't): you assume everyone sees the world as you do. And so novels by white straight cis people end up full of white straight cis characters. We've never needed to notice that that's not how everyone is.
There are multiple reasons to vary your cast beyond your own identity, from pragmatic writerly reasons to more ideological ones. A variety of characters with a variety of experiences makes a better book than a homogenous cast. The real world has a wider mix of people, so you can draw on that in your writing. Thinking ideologically, I don't believe we should invent worlds that blindly replicate ourselves and erase anyone not-like-us.
The only identity position where I lack privilege is gender: I'm a woman, so my awareness of gender issues is sharpened. I notice all-male line-ups, whether in novels or comedy panels. In my own writing, I have one deliberate tactic I stick to religiously: whenever I have a traditionally male profession, doctor / lawyer / banker / etc, I make it a woman, as a matter of principle. "Man" is not the default in my writing. Only recently, though, have I become increasingly aware of all my other defaults: everyone's straight, white, and cis until proven otherwise. I want to change that - partly because I do believe that representation is an important ideological issue, and also because I want my own writing to be better.
When you're writing another identity position, don't make the character all about that. I'm a woman: that's not the headline definition of my personality. That's not the key struggle in my life. It's an aspect of a much more interesting life, and of a person who wishes no-one even bloody knew what gender I am, so I can get on with being me and not be shoved into pink boxes all the time. You see? It's not my defining identity (that's "writer"); it's not my central struggle; it is a significant part of my experience, whether I like it or not. In Cheryl Morgan's terms "we're people not issues". Likewise, a gay character doesn't need to be all about them being gay and coming out, a disabled character doesn't have to be about her disability, a trans character can just be a woman who also happens to have a trans history, and so on.
My own approach is to invent the character first, start with the person, and then add in identity positions. (One of my students avoids her own defaults by using dice: a throw of the dice decides every identity position for a character, so she's never using her own assumptions.) Yes, those identity positions will shape how the characters experience the world, and perhaps limit their possibilities in some surprising ways, or throw up some issues you've never had to deal with yourself ("So how can I write this scene set on top of St Mary's if my character's in a wheelchair? It's all steps!"), but your character is first off a person, not an issue.
Writing from other identity positions will also always be problematic, though. If I start declaring what it's like to be black, from my position of white privilege, that can be read as taking over, talking over, talking for when I have no right to, and at the extreme end regarded as a form of colonisation. Likewise, being cis and writing a trans character might be an issue. Before writing this, I spoke to Cheryl Morgan, to get some input on how trans people might view a cis woman like me writing a trans character. "There are some trans folk for whom any thing a cis person writes about us will be wrong!" she replied. "Personally I am happy to see people try, as long as they are willing to accept feedback. I have seen a lot of good stuff. But it is possible to get it horribly wrong, even with the best of intentions." That raised the three key issues very neatly. First, you have to be willing to accept feedback. Vast swathes of writing are about writing things we haven't experienced ourselves; that's a normal thing for a writer to do, but if you don't know what something's like, you can read up about it, follow some useful pages on Facebook or people on Twitter, ask a few people if you can run it by them. Remember, though, that no-one is representative (and most don't want to be). I'll happily offer my experience of being a woman, but I can't speak for all women, and assuming I can is insulting: it makes women cookie-cutter identikits, completely defined by their gender.
Second, you might still get it wrong, as with anything you write. And third, the biggest issue: some people might never accept your writing outside your own experience or position of privilege. I do understand and respect that argument, but I think it is better to take that risk of "speaking for others" than to write a world in which gay, trans, and non-white people are invisible.